Mega Code Archive

 
Categories / Java Tutorial / JSTL
 

Use ChooseWhenOtherwise to Check Form CheckBox Data

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">     <c:choose>       <c:when test="${adj == 'satisfactory'}">          <font size="+2">       </c:when>       <c:otherwise>          <font size="-2">       </c:otherwise>     </c:choose>     <li><c:out value="${adj}"/></li>     </font>   </c:forEach>  </c:when>  <c:otherwise>   You didn't choose any feedback checkboxes.  </c:otherwise> </c:choose>