i have a page in jsp where i am dynamically displaying records from the database in a table, with dynamic rows being generated. With every row, there is a radio button so that the user can select one row.
The code for page1.jsp is:
<form action="page2.jsp" method="post">
<table>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Users/hp/Documents/Sample1.accdb";
Connection con = DriverManager.getConnection(database, "", "");
Statement stmnt = con.createStatement();
String source=request.getParameter("from");
String dest=request.getParameter("to")
ResultSet resultset = stmnt.executeQuery("select * from Trains123 where From='" +source+ "' and To='" +dest+ "' ");
while(resultset.next())
{
%>
<tr>
<td><% out.println(resultset.getString("From")); %></td>
<td><% out.println(resultset.getString("To")); %></td>
<td><% out.println(resultset.getString("TrainName")); %></td>
<td><input type="radio" name="TName" value="<%= resultset.getString("TrainName")%>">book</td>
</tr>
</table>
</form>
and the code on page2.jsp is:
<% out.println(request.getParameter("Tname")); %>
There is no problem with the record set, the values are getting printed. but the radio button is not being displayed.Also, If there are 2 records in the recordset, only the first one gets printed without the radio button. I debugged the file, the control stops at the radio button line.
I have no idea, where the error is and what is the problem with giving dynamic value to the radio button. All i want to do is to find out the row selected by the user.