How can I retrieve an entire database in JSP and compare the first record with the first parameter obtained from a HTML form, the second record with the second parameter obtained from the HTML form and so on..??
Here is my code:
MS-ACCESS database:-
database name: question
table name : ques
qno answer
1 A
2 A
3 A
index.html
<html>
<head>
<title>RESULT</title>
<style type="text/css">
body { margin:10px; font-size:13pt;}
span { font-size:14pt; color:red; }
form { margin:30px; }
h { font-size:19pt; color:red;}
</style>
</head>
<body>
<center><h> Quarterly Examination - Question Paper </h></center>
<form name="form" method="post" action="time.jsp"/>
1. When did the First World War start? <br/>
<input type="radio" name="1" value="A"/> 1914     
<input type="radio" name="1" value="B"/> 1915     
<input type="radio" name="1" value="C"/> 1916     
<input type="radio" name="1" value="D"/> 1917
<br/><br/>
2. Who was called 'The Fuhrer'? <br/>
<input type="radio" name="2" value="A"/> Hitler     
<input type="radio" name="2" value="B"/> Mussolini     
<input type="radio" name="2" value="C"/> Herbert Hoover     
<input type="radio" name="2" value="D"/> Frankin Roosevelt
<br/><br/>
3. Which crown prince's murder triggered the First World War? <br/>
<input type="radio" name="3" value="A"/> Austria     
<input type="radio" name="3" value="B"/> Spain     
<input type="radio" name="3" value="C"/> England     
<input type="radio" name="3" value="D"/> France
<br/><br/>
                             <input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
time.jsp
<%@page contentType="text/html" import="java.util.*" import="java.sql.*"%>
<%
String ans1 = request.getParameter("1");
String ans2 = request.getParameter("2");
String ans3 = request.getParameter("3");
String query = "select * from ques";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c1 = DriverManager.getConnection("Jdbc:Odbc:question","","");
Statement state = c1.createStatement();
ResultSet r1 = state.executeQuery(query);
while(r1.next())
{
}
response.getWriter().println("<body><br/><br/><center><h1> Exam Result </h1>");
response.getWriter().println("Your score is :");
response.getWriter().println("</center></body>");
%>
I dont know how to compare the values inside the while loop.