standard taglib • implementation of the JSP Standard Tag Library • support development comments to JSR-52
Examples Introduction • General Purpose • Conditionals • Iterators • Import • I18N & Formatting • XML • SQL • Functions • TLV • Misc.

## Iterator Tags Examples

### Simple

Simply displays the default `toString()` value of the items in the `Customers` collection.

### Range

Another simple example. Similar to the previous one, except that in this case there is no collection to iterate over. The `items` attribute is optional in the `<forEach>` tag. When it is not specified, the range attributes must be used to iterate a specific number of times over the tag's body. In this example, we simply iterate over the integer values specified by the range attributes.

### Data Types

The `<forEach>` tag supports a large number of data types for the collection of objects to iterate over. In this example, we feature the following data types: array of primitives, array of objects, Enumeration, Properties (Map), String (Comma Separated Values).

### Iteration Status

The iterator tag exposes a wealth of information relative to the iteration taking place. This example features some of that status information.

### Collaboration

The iterator tags expose interface IteratorTag to allow custom tags to establish implicit collaboration. This example shows two custom tags, <even> and <odd> who take advantage of this implicit collaboration.

### <forTokens>

The <forEach> tag provides the basic iteration capabilities. <forTokens> is a specialization for the handling of Strings of tokens. Essentially the same as <forEach>, except that it only applies to Strings of tokens and that it has an extra attribute "delims" to specify the token delimiter.

### Extensibility

JSTL exposes in its API the abstract class LoopTagSupport to facilitate the implementation of custom iterator tags that leverage the standard iteration behavior defined in JSTL. This example shows a custom iterator tag that shows all Locale objects available in the server and a custom conditional sub-tag that display the default locale.

standard taglib • implementation of the JSP Standard Tag Library • support development comments to JSR-52