Iterative Tags

A common requirement for Web pages is to provide a variable number of items in a common format. Although the JSTL core and XML <forEach> tags can now be used for iterations, there are occasions when you will need to write your own custom tags to perform iteration.

Iterative custom tags interact with the processing of the start and end tags to ask for the tag body to be processed again, and again, and again….

An iterative tag must implement the IterationTag interface. This is most commonly achieved by sub-classing the BodyTagSupport class. The doAfterBody(), method must return IterationTag.EVAL_BODY_AGAIN to process the body again or Tag.SKIP_BODY to stop the iteration. Typically, the doAfterBody() method will change the data for ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition 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.