but using the above code it only displays the last value. my 1st page is <% try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sim?"+"user=root&password=yes");
String n[]=new String[50];
String a[]=new String[50];
String id[]=new String[50];
int c=0,i=0;
String s=null;
String s1=request.getParameter("c_id");
Statement st1=(Statement)con.createStatement();
out.println("<br>");
out.println("class");
out.println(s1);
out.println("<br>");
PreparedStatement pstmt=con.prepareStatement(" SELECT * FROM student, student_class WHERE student.s_id = student_class.s_id AND c_id = ? ");
pstmt.setString(1,s1);
ResultSet rs2= pstmt.executeQuery();
while(rs2.next())
{
s=rs2.getString("s_id");
out.println("Name: ");
String s2=rs2.getString("fname");
String s3=rs2.getString("mname");
String s4=rs2.getString("lname");
out.println(s);
out.println(s2);
out.println(s3);
out.println(s4);
n[c]=s;
out.println("<br>");
out.println("---------------------");
c++;
%>
<form name="stu_class" method="post" action="stu_class1.jsp" >
<table>
<tr>
<br><input type="hidden" name="c_id" value="<%=s1%>"/>
PROMOTED<INPUT type=radio name="radio<%=i%>" value="p" request>
NOT PROMOTED:<INPUT type=radio name="radio<%=i%>" value="f" checked="true">
<td style="padding-top:2%">
</form>
<input type="hidden" name="c" value="<%=c%>"/>
</table>
<%
i++;
}
session.setAttribute("n",n);
%>
<TD align="right" style="padding-right:20%">
<INPUT type="submit" value="Update" name="submit" >
<% }
catch (SQLException e)
{
throw new ServletException("Servlet Could not display records.", e);
}
and my 2nd page is
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sim?"+"user=root&password=yes");
String s1=request.getParameter("c_id");
String s=request.getParameter("s_id");
String c=request.getParameter("c");
String id[]=new String[50];
int t=Integer.parseInt(c);
out.println(c);
out.println(s);
out.println(s1);
// String values[] =(String [])request.getParameterValues("a");
String val[]=(String [])session.getAttribute("n");
// out.println(values[0]);
// out.println(val[0]);
for(int j=0;j<t;j++)
{
out.println("<br>");
out.println(val[j]);
}
for(int i=0;i<t;i++)
{
out.println("test");
id[i]=request.getParameter("radio"+i);
out.println(id[i]);
}
}
catch (SQLException e)
{
throw new ServletException("Servlet Could not display records.", e);
}
%>
the problem is it displays only the last value of radio button