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.

[3361 byte] By [tomcat_III] at [2007-9-26 4:35:37]
# 1

although U have ur if stmnt coded in such a manner that it will process 1 form or another, I think the HTML is where the problem. I think that the java code, including the ifs are seperated from the html and u are then left with 2 form stmnts on the same page , both with the same name and both with submit buttons. I have not tried the code but I suggest naming the 2nd form something different....I may be wasting ur time but its where I would look.

Peter

peterbarry2002 at 2007-6-29 17:52:52 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...