index.jsp
<form method="post" action="checkbox.jsp"> <P>Please check adjectives you would use to describe this web site's customer service:</p> <P>Atrocious <input type="checkbox" name="feedback" value="atrocious"/></p> <P>Loathsome <input type="checkbox" name="feedback" value="loathsome"/></p> <P>Flagitious <input type="checkbox" name="feedback" value="flagitious"/></p> <P>Satisfactory <input type="checkbox" name="feedback" value="satisfactory"/></p> <P><input type="submit" value="Submit" /></p> </form>
checkbox.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <c:choose> <c:when test="${not empty paramValues.feedback}"> You described our customer service as <ul> <c:forEach items="${paramValues.feedback}" var="adj"> <li><c:out value="${adj}"/></li> </c:forEach> </ul> </c:when> <c:otherwise> You didn't choose any feedback checkboxes. </c:otherwise> </c:choose>
24.14.Form CheckBox | ||||
24.14.1. | Use ForEach to Check Form CheckBox Data | ![]() | ||
24.14.2. | Use Choose/When/Otherwise to Check Form CheckBox Data | ![]() | ||
24.14.3. | Use Bean to Deal with CheckBox | ![]() |