How to Pass a Check Box Value Into a Servlet
A Java servlet lets you process JSP pages that contain form fields such as a check box. If you do not specify a check box value, the value passed is "on." You can specify a value using the "value" property in the JSP form. Then, you use the "getParameter" function to retrieve the check box value in the processing page.
Instructions
-
-
1
Open your JSP editor and open the Web project. Double-click the JSP form page and the processing page that you want to use to retrieve the check box value.
-
2
Add the following code to add a check box with an associated value:
<input type="checkbox" value="myvalue" id="check">
The value passed from the form is "myvalue."
-
-
3
Open the Java servlet processing page and add the following code to retrieve the value from the check box:
string checkboxvalue = request.getParameter("check");
-
1