tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Du <>
Subject Re: How to break a loop in JSTL c:foreach
Date Thu, 26 Sep 2002 06:28:52 GMT
I think breaking a loop is a general and useful feature for better 

Here is a case:

Assuming a multiple select control in a form, and a java variable 
id2textMap keeps all the items showed in the select control, each entry 
in the map is responding to an item in the control and "id" is the value 
and "text" is the text. A variable selIDs keeps all selected items. Now 
the jstl codes to generate the select control is as follows:

<select name="selIDs" size="5" multiple>
<c:foreach var="entry" items="id2textMap">
   <option value="<c:out value="${entry.key}"/>"
     <c:foreach var="selID" items="selIDs">
       <c:if test={selID==entry.key}>
         <%-- I WANT TO BREAK THE LOOP HERE -->
   <c:out value="${entry.value}"/>

In our project, we have a page that contains more than 50 select 
controls like that and the performance to display that page with JSTL is 
not good.


Eric Du

Shawn Bayern wrote:
 >>Would it be possible to have an loop tag which iterates based on a
 >>boolean condition?

 > A <c:while>?  Yes, additions like this are always possible in future
 > versions if there's enough perceived need.
 > I'd suggest mailing with the suggestion.  Be sure
 > to indicate the situations where this would be useful to you, with as
 > specific examples as possible.
 > Best,

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message