abhinavM 0 Newbie Poster

I have a jsp page where I am accessing data from the database and showing the data in table on the browser with radio buttons in between.And then there is a submit button on whose click the control is transferred to a servlet where I reading the status of the radio buttons and inserting in the new database table the response accordingly.I am able to read that in a row out of the four radio buttons which was clicked but I am unable to transfer the option (which is a string) from the jsp page to the servlet

Below is my jsp code where I am displaying data from database in the table.


index.jsp

<form name="myform" id="myform" action="/proj/Test" method="get">
 
    <input type="text" name="Emp_id">
 
      <TABLE cellpadding="15" border="1" style="background-color: #ffffcc;">
 
      <%
 
      while (rs.next()&&(i<=4)) {
 
      %>
 
       <TR>
        <TD><%=rs.getString(1)%></TD>                                                                                                          //I want to pass this 
        <TD><%=rs.getString(2)%></TD>                                                                                                             value for each row
 
        <TD><input type='radio' name="radio<%= i %>" value="radio1"><%=rs.getString(3)%></TD>                     //I want to pass                
        <TD><input type='radio' name="radio<%= i %>" value="radio2"><%=rs.getString(4)%></TD>                     //these values  
        <TD><input type='radio' name="radio<%= i %>" value="radio3"><%=rs.getString(5)%></TD>
        <TD><input type='radio' name="radio<%= i %>" value="radio4"><%=rs.getString(6)%></TD>
 
    </TR>  
 
      <%i++; %>                                                      
 
      <%   }   %>
 
 
      <% 
      rs.close();
 
      statement.close();
 
      connection.close();
 
      } catch (Exception ex) {
 
      %>
 
 
      <font size="+3" color="red"></font>
 
     <%   
 
     out.println("Unable to connect to database."); 
 
           }
       %>
 
 
 
      </TABLE>
 
 
 
   `	
 
 
  <input type="submit" name="submit" value="Submit" align="middle" >
  </form>

Here is my servlet code where i am reading actions of radio buttons

test.java

for(int i=1;i<=4;i++)
		{
		//if(request.getParameter("radios") != null) {
            if(request.getParameter("radio"+i).equals("radio1")) {
                System.out.println("Radio button 1 was selected.");
 
//HERE I WANT TO GET rs.getsString(1) & rs.getString(3) value from index.jsp for the first row of table on the first run of for loop.For 2nd run 2 //nd row of database table should be accessed
 
 
            }
            else if(request.getParameter("radio"+i).equals("radio2"))
            {
            	 System.out.println("Radio button 2 was selected.");
 
//HERE I WANT TO GET rs.getsString(1) & rs.getString(4) value from index.jsp for the first row of table on the first run of for loop.For 2nd run 2 //nd row of database table should be accessed
 
 
            }
            else if(request.getParameter("radio"+i).equals("radio3"))
            {
            	 System.out.println("Radio button 3 was selected.");
 
//HERE I WANT TO GET rs.getsString(1) & rs.getString(5) value from index.jsp for the first row of table on the first run of for loop.For 2nd run 2 //nd row of database table should be accessed and so on for every run
 
 
            }
 
            else if(request.getParameter("radio"+i).equals("radio4"))
            {
            	 System.out.println("Radio button 4 was selected.");
 
//HERE I WANT TO GET rs.getsString(1) & rs.getString(6) value from index.jsp for the first row of table on the first run of for loop.For 2nd run 2 //nd row of database table should be accessed and so on for every run
 
 
 
 
 
 
            }
 
            else System.out.println("No button selected");
		}