HTML Select Element That Remembers Previous Selection in JSTL
Here is an JSTL code example that shows how to build a select box that remembers the previous selection.
<select name=’days‘>
<c:forTokens items="7;14;30;60;180; 365" delims=";" var="current">
<c:choose>
<c:when test="${current==param.days}">
<OPTION selected>
</c:when>
<c:otherwise>
<OPTION>
</c:otherwise>
</c:choose>
<c:out value="${current}" /></option>
</c:forTokens>
</select>
Each iteration checks an option value against a request parameter that contains the value of the selected option element. If they are equal, the HTML option tag is given a selected attribute.
