changing destination JSP page and servlet

JeroSivecoirl

New Member
I'm new to JSP and Servlet so please bear with me for a while!I have a problem regarding the communication between JSP and Servlet.I am trying to create a LogIn Page.This is my Index JSP page for LogIN\[code\]<%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%><html> <head><title> index.jsp</title></head> <body bgcolor="orange"> <h2> <font color=white> JSP index.jsp at</font> <%= request.getContextPath () %> <font color=white> </font></h2><hr> <form action="LibrarySysServlet" method ="POST"> <font color=navy><h3>Login</h3> <table> <tr> <td> MemberId </td> <td align="left"><input type="text" name="memId" length="30"/></td> </tr> <tr> <td> Password </td> <td align="left"><input type="text" name="password" length="30"/></td> </tr> </table> <br> <p><input type="submit" value="http://stackoverflow.com/questions/15629267/Submit"/></p> </font> </form> <br> </body></html>\[/code\]I am really confused on what to put for the form action for the index page when logging in as the destination changes according to whether the logIn is correct or not.For my Servlet side, i tried to scan in index page and pass it through a function to check whether logIn is correct and redirect it according to the different answer.However when run, it does not redirect but it just proceeds to whatever was specified in form action. Short snippet of the code (didn't paste the whole thing because it was too long):\[code\] RequestDispatcher dispatcher; ServletContext servletContext = getServletContext(); //links to index.JSP String page = request.getPathInfo(); page = page.substring(1); if ("index".equals(page)) { if (logIn(request)) { dispatcher= servletContext.getRequestDispatcher("/result.jsp"); } else { dispatcher= servletContext.getRequestDispatcher("/Menu.jsp"); } }\[/code\]HELP really confused ! WHat am i doing wrong??
 
Back
Top