12.5. Looping with the forTokens Tag
The forEach tag lets you loop down comma-delimited strings. But, what if the tokens are delimited by something other than a comma? Or, what if more than one character can separate the tokens? Enter the forTokens tag. In addition to the six attributes available in forEach (var, begin, end, step, items, status), forTokens has a delims attribute. This attribute specifies the delimiters, just as with the second argument to the StringTokenizer constructor.
Hmm, forTokens sounds an awfully lot like forEach. Were the JSTL developers able to leverage the forEach code when developing forTokens ? Yes! And you can too. JSTL provides a class called IteratorTagSupport that lets you create custom tags that extend the behavior ...
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.