When I input values into the form, it is going through the if-else accordingly.
However, when I pass parameters via the URL like this:
http://localhost:8080/sessiondemo/index.html?user=wronguser&pass=wrongpass
It is not going through anything. None of the println's are executing (not even the user/pass/end). It just goes back to the form.
May I know why is this so?
<form action = "processlogin.cgi" method = "post">
<p>Username: <input type = "text" name = "user" size = "25"/></p>
<p>Password: <input type = "password" name = "pass" size = "25"/></p>
<input type = "submit" value = "Login"/>
</form>
@WebServlet("/processlogin.cgi")
public class ProcessLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String user = request.getParameter("user");
String pass = request.getParameter("pass");
System.out.println("User: " + user);
System.out.println("Pass: " + pass);
if(UserManager.isValidUser(user, pass)) {
System.out.println("valid");
} else {
System.out.println("invalid")
}
System.out.println("end");
}
}