This is what happens to me. I have one .jsp file. However, I have two forms with several inputs inside these forms.
What is the best way to discover that one form has been presented but not the other? Here is an example: I have this form:
<form name = "login" action="index.jsp" method="get"> Username: <input id="username" name="username" type="text"/><br/> Password: <input id="password" name="password" type="password"/> <input type="submit" Value="Login" ></input> </form>
If this button is pressed, I want to run this code:
String username = request.getParameter("username"); String password = request.getParameter("password"); if((username!= null && !username.trim().equals("")) && (password != null && !username.trim().equals(""))) { DBentry DBentry=new DBentry(); boolean flag = DBentry.isTaken(username); if(flag) {%><script type="text/javascript">alert("Login Successful!");</script><% } else { %><script type="text/javascript">alert("Unrecognized username. Please register!");</script><% } } else { %><script type="text/javascript">alert("Please enter both a username and password!");</script><% }
Further, I would have something similar, but it would have seemed a different form. Thanks!
source share