
how to retrive multiple values of checkboxes of jsp in action class

JSP Retrieve checkbox values
1)checkbox.jsp:
<html> <body> <form method="post" action="../Action" > Select Languages:<br> <input type="checkbox" name="lang" value="C/C++">C/C++<br> <input type="checkbox" name="lang" value="JAVA">Java<br> <input type="checkbox" name="lang" value="C#">C#<br> <input type="checkbox" name="lang" value="PERL">PERL<br> <input type="checkbox" name="lang" value="PYTHON">PYTHON<br> <input type="submit" value="Submit"> </form> </body> </html>
2)In Action class, use the following code:
if(request.getParameter("lang")!=null){
String st[]=request.getParameterValues("lang");
out.println("You have selected:");
for(int i=0;i<st.length;i++){
out.println(st[i]);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.