Java Tutorial/JSTL/Form CheckBox
Use Bean to Deal with CheckBox
index.jsp
<source lang="java">
<HTML>
<BODY bgcolor="white">
<FORM TYPE=POST ACTION=checkresult.jsp>
Check all Favorite fruits:
<input TYPE=checkbox name=fruit VALUE=apples> Apples
<input TYPE=checkbox name=fruit VALUE=grapes> Grapes
<input TYPE=checkbox name=fruit VALUE=oranges> Oranges
<input TYPE=checkbox name=fruit VALUE=melons> Melons
<INPUT TYPE=submit name=submit Value="Submit">
</FORM>
</BODY>
</HTML></source>
Use Choose/When/Otherwise to Check Form CheckBox Data
index.jsp
<source lang="java">
<form method="post" action="checkbox.jsp">
Please check adjectives you would use to describe this web site"s customer service:
Atrocious <input type="checkbox" name="feedback" value="atrocious"/>
Loathsome <input type="checkbox" name="feedback" value="loathsome"/>
Flagitious <input type="checkbox" name="feedback" value="flagitious"/>
Satisfactory <input type="checkbox" name="feedback" value="satisfactory"/>
<input type="submit" value="Submit" />
</form></source>
Use ForEach to Check Form CheckBox Data
index.jsp
<source lang="java">
<form method="post" action="checkbox.jsp">
Please check adjectives you would use to describe this web site"s customer service:
Atrocious <input type="checkbox" name="feedback" value="atrocious"/>
Loathsome <input type="checkbox" name="feedback" value="loathsome"/>
Flagitious <input type="checkbox" name="feedback" value="flagitious"/>
Satisfactory <input type="checkbox" name="feedback" value="satisfactory"/>
<input type="submit" value="Submit" />
</form></source>