2 questions 2004-02-06 - By Johannes
Back hi pinguti,
1) response.sendRedirect(redirectUrl) will tell the browser to get the contents from the url given (you can also use relative urls).
dispatcher.forward will invoke the servlet/jsp given and will hand the complete request + response object to it (forward it), so in fact control is passed to the invoked servlet/jsp. you usually use this within an MVC pattern where a servlet does the control work and will fetch data from backend systems, and the jsp takes over to do the rendering/view work.
2) yes, this is ok.
true will create a new session, if none exists. false will not create a new session if there isn't already one. it will simply return null in this case.
I hope this helps, Johannes
Pinguti Sridevi <zava_doubts@(protected)> 22.01.2004 11:38 Please respond to "Tomcat Users List" <tomcat-user@(protected)>
To anand <anand@(protected)>, javagroup <gurgaon_jug@(protected)>, parvez <parvezs@(protected)>, tomcat <tomcat-user@(protected)> cc
Subject 2 questions
1) What is the differences between two ? res.sendRedirect(" http://localhost:8080/authendication/Logout/body_logout.jsp"); or getServletContext().getRequestDispatcher("/authendication/Logout/body_logout .jsp").forward(req, res); 2) 1 )Whenever for the first time if the user enters, I want to store the username,rights in the session How to do it in Servlet. Is it right ? HttpSession session = request.getSession(true); //can u tell me when we have keep false here. session.setAttribute("username",usernamevalue); session.setAttribute("rights",rights");
-- ---- ---- ---- ---- ---- ----- Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!
|
|