index.jsp
<HTML>
<HEAD>
<TITLE>Submitting Check Boxes</TITLE>
</HEAD>
<BODY>
<H1>Submitting Check Boxes</H1>
<FORM action="basic.jsp" method="post">
<INPUT TYPE="CHECKBOX" NAME="checks" VALUE="check1" CHECKED>
Checkbox 1
<BR>
<INPUT TYPE="checkbox" NAME="checks" VALUE="check2">
Checkbox 2
<BR>
<INPUT TYPE="checkbox" NAME="checks" VALUE="check3">
Checkbox 3
<BR>
<INPUT TYPE="submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>
basic.jsp
<HTML>
<HEAD>
<TITLE>Reading Checkboxes</TITLE>
</HEAD>
<BODY>
<H1>Reading Checkboxes</H1>
You checked:
<BR>
<% String[] items = request.getParameterValues("checks");
for(int i = 0; i < items.length; i++){
out.println(items[i] + "<BR>");
}
%>
</BODY>
</HTML>
Download: UseLoopToReadFormControls.zip( 1 k)