| Author |
RequestDispatcher
|
Lucky Singh
Ranch Hand
Joined: Jan 19, 2004
Posts: 125
|
|
Is this right? public class Login extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { String user, pass; boolean response = false; user = req.getParameter("username"); pass = req.getParameter("password"); DatabaseChecker ct = (DatabaseChecker)(getServletContext().getAttribute("ct")); response = ct.validate(user,pass); if(response == true) { HttpSession userSession = req.getSession(true); userSession.putValue("userName", user); RequestDispatcher rd = getServletContext().getRequestDispatcher("/Welcome.jsp"); if (rd != null) { rd.forward(req,res); } } else { //Return to LoginPage. RequestDispather rd2 = getServletContext().getRequestDispatcher("/Login.jsp"); rd2.forward(req,res); } }//end doGet. }//end Login. [ March 24, 2004: Message edited by: Lucky Singh ]
|
 |
Kaustubh Patil
Ranch Hand
Joined: Aug 13, 2001
Posts: 164
|
|
|
r u having any problems in executing it ?
|
Kaustubh. Mumbai, India.
|
 |
Lucky Singh
Ranch Hand
Joined: Jan 19, 2004
Posts: 125
|
|
|
Would like to knwo if it is correct in syntax.
|
 |
Kate Head
Ranch Hand
Joined: Oct 31, 2002
Posts: 67
|
|
Hi there, I was told to put return; after the call to rd.forward(req, resp); I also used String nextScreen to hold the "/Welcome.jsp" or "/Login.jsp" names so used the following format: Hope that helps. All the best, Kate!!  [ March 24, 2004: Message edited by: Kate Head ]
|
 |
 |
|
|
subject: RequestDispatcher
|
|
|