Sometimes there is a need to pass a collection of values from HTML from to server. To achieve that a list of parameters with the same name is used. In our sample form we use a set of checkboxes with the same name.

A collection of parameteres may be accessed through the expression ${paramValues.name}, where name is the name of the parameter you're looking for. The result of such expression contains all these values.

In our tip all the checkbox parameters have the same value for the name attribute: feedback. Users can choose as many check boxes as they feel are appropriate, and the expression ${paramValues.feedback} will contain a collection of all the parameters

A form with checkbox parameters:

...
<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>
...
////////////// a page to handle checkbox parameters:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<c:choose>

////////////// Decides if there are any feedback params"

	<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>