• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

why no while loop tag in JSTL

 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am surprise that there is no direct support for while loop in JSTL. Even though it can be simulated by combination of if and forEach, I feel that JSTL is missing it.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just out of interest, is there any specific reason that you feel a "while" tag would be a useful addition?
If you take the MVC approach, JSP is used to render the pages of a web application which means that the controller should setup the model appropriately. Using a while loop tends to imply that a certain degree of logic is embedded within the page.
Just my opinion...
Simon
[ October 31, 2002: Message edited by: Simon Brown ]
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Simon -- as did the JSTL expert group. We couldn't come up with a compelling reason to introduce a <c:while> tag.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case you don't want to iterate over Collections, you can use <c:forEach> as a conventional loop equivalent by the following approach:

<c:set var="startIndex" scope="page" value="0"/>
<c:set var="endIndex" scope="page" value="12"/>

<select name="milestone_count" id="milestone_count">
    <option value="">-select-</option>
    <c:forEach begin="${startIndex}" end="${endIndex}" step="1" var="index">
        <option value="${index}">${index}</option>
    </c:forEach>
</select>

This will produce a select drop down ranging from 0 to 12
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic