Hi All,

Hi All,

I am trying to pass the value of selected radio button from one jsp page to another but I am null values.

Below is my code:-

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        int i=1;
        String url = "jdbc:mysql://";
        String username1="root";
        String password1="root";
        PreparedStatement st = null;
        ResultSet results = null;
         int iQuestionID=3;
            try {
                Connection con= DriverManager.getConnection(url,username1,password1);
                String sql="SELECT  Questions.Question, Questions.option1, Questions.option2,Questions.option3, Questions.option4,Questions.correctanswer FROM Questions order by RAND() limit ?";
                st = (PreparedStatement) con.prepareStatement(sql);
                results = st.executeQuery(); 
                while (results.next()) {
    String r1, r2, r3, r4, r5,r6;
    r1 = results.getString(1);
    r2 = results.getString(2);
    r3 = results.getString(3);
    r4 = results.getString(4);
    r5 = results.getString(5);
    r6 = results.getString(6);
<form name="form1"  method="post" action="Results.jsp" > 
<table border="1" width="500px" bgcolor="white" cellspacing="0" cellpadding="0">
<td width="100%"> 
<h2 align="center"><font color="red">Online Quiz Application</font></h2>
<b>Select Correct Answer</b>
<table border="0" width="500px" cellspacing="2" cellpadding="4">
<td width="50%"> Question:</td>
<td><input type="hidden" name="correctAns<%= i %>" value="<%= results.getString(6) %>" /></td>
<td><%= results.getString(1) %></td></tr>
1: <input type="radio" name="a<%= i %>"  id="a<%= i %>" value="<%= results.getString(2) %>" /></td>
<td><%= results.getString(2) %></td></tr> 
2: <input type="radio" name="a<%= i %>" id="a<%= i %>" value="<%= results.getString(3) %>" /></td>
<td><%= results.getString(3) %></td></tr>
3: <input type="radio" name="a<%= i %>" id="a<%= i %>" value="<%= results.getString(4) %>" /></td>
<td><%= results.getString(4) %> </td></tr>
4: <input type="radio" name="a<%= i %>" id="a<%= i %>" value="<%= results.getString(5) %>" /> </td>
<td> <%= results.getString(5) %> </td></tr>
            <% if (i==iQuestionID)
    <INPUT type = "submit" name="addSubmit" value = "Press to Submit">
    <% } %>
}catch (Exception ex) {
    }finally {     
    } %>

The code in Results.jsp

String id[]= new String [5]; 
for (int i=1;i<5; i++) 

But in Results.jsp , I am getting null values.

I even tried the code with servlets.I was able to display the questions of quiz but I am unable to fetch the value of selected radio button.

Any help in fetching the value of selected radio button will be much appreciated.