I am a beginner. I want to pass an array of check box values from one JSP page to another. The page getting data is
<%
ResultSet rs=s.notapprovedqns();
%>
<%
while(rs.next())
{ %>
<tr><td><input name="qns[]" type="checkbox" value="<% out.println(rs.getInt("question_id")); %>" /></td><td><center><%=rs.getString("question_id") %></center></td><td><%=rs.getString("question") %></td></td></tr>
<%
}
%>
How can i receive check box values in JSP another page. I have tried the following code but its not working properly
String[] h=null;
h=request.getParameterValues("qns[]");
But its passing the value
[Ljava.lang.String;@a0a595
Please somebody help me to solve this problem.
You Can use it as follows. in Form
<form method="post" action="process.jsp">
<input type="checkbox" name="list" value="value1">
<input type="checkbox" name="list" value="value2">
<input type="checkbox" name="list" value="value3">
</form>
In process.jsp
String[] ids=request.getParameterValues("list");
// this will get array of values of all checked checkboxes
for(String id:ids){
// do something with id, this is checkbox value
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With