12.3. Looping with the forEach Tag

Perhaps the single most important tag in JSTL is forEach. It provides the ability to loop with explicit numeric values or to iterate down an array, Collection, Iterator, Enumeration, Map, ResultSet, or comma-separated String. The forEach tag also lets you access an IteratorTagStatus object that provides a variety of information about the loop status.

The forEach tag has six available attributes: var, begin, end, step, items, and status. The following list summarizes their use; the following subsections give details and examples.

  • var. The iteration variable. When you loop with explicit numeric values, the variable contains the value of the loop index. When you iterate over data structures, the variable contains ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.