Processing HTML forms using JSP
I am writting a jsp application that behaves like the windows trouble shooters. It asks some questions and then gives some adivce. I have written the application, it is made up of a form that asks questions which can be answered by selecting a radio button. The problem is that I have to press the submit button twice before the application responds properly. The following is the code that I have written: -
<HTML>
<head>
<title>LAN Implementation Expert System</title>
</head>
<body>
<jsp:useBean id="It" scope="session" class="Security"/>
<jsp:useBean id="Connection" scope="session" class="JDBCBean"/>
<jsp:useBean id="FindNext" scope="session" class="ResolverBean"/>
<% if ((It.getPasswd()!=null) && (It.getUsername()!=null)) {%>
<% if (It.checkPasswd()) { %>
<% if (request.getParameter("nextquestion")!=null)
Connection.runQuestion(FindNext.getNextquestion());
System.out.println(FindNext.getNextquestion()); %>
<center> <h1>Welcome <jsp:getProperty name="It" property="username"/></h1></center>
<hr>
<%=It.getUsername()%>
<form method=get>
<%Connection.runQuestion(FindNext.getNextquestion());%>
<%=Connection.getCell(1,1)%>
<%int i;
for (i=2; i<Connection.calcAnswers()+2; i++) {%>
<input type=radio name=nextquestion value=<%=i-1%>><%=Connection.getCell(i,1)%>
<%}%>
<input type="submit" value="Next" >
<input type="reset" value="Reset" >
</form>
<jsp:setProperty name="FindNext" property="nextquestion"/>
<% } else { %>
<jsp:forward page="error.jsp"/>
<%}%>
<%} else { %>
<center><H1>Welcome</H1></center>
<center><img src="hub.jpg"></center>
<p>This is the login page of the expert system. Please enter your name and password in order to login to the system.
<form method=get>
<table>
<tr><td>Enter Your Name: -</td>
<td><input type="text" name="username" size=25></td>
</tr>
<tr>
<td>Enter Your Password: -</td>
<td><input type="password" name="passwd" size=25></td>
</tr>
<td><input type="submit" value="Submit"></td>
<td><input type="reset" value="Reset"></td>
</table>
</form>
<jsp:setProperty name="It" property="username"/>
<jsp:setProperty name="It" property="passwd"/>
<% } %>
<body>
</HTML>
I would appreciate any help.

