10 Iterating with tags In this chapter
CHAPTER 10 Iterating with tags At the end of chapter 8, we used our newly created JavaBean tags to export an Enumeration which was then iterated over with a scriptlet. Let s take another look at this JSP fragment.
| Header | Value |
|---|
As you can see (note the highlighted code), although our JavaBean tags greatly reduce the need for scriptlets, we are still unable to avoid them when working with indexed JavaBean properties that have more than one value. In cases of multivalued properties (Enumerations, arrays, etc.) we typically want to loop through (iterate) and perform a function with each value in the property. Without a tag to handle this iteration, we re left using a scriptlet like the one here. This is unfortunate since we want to be able to provide our JSP authors with the ability to perform common functions on JavaBeans without prior knowledge of Java. Ideally, we d like to offer them a very user-friendly JSP custom tag that would work for iteration. Iteration, especially enumerating some value, can be very declarative, and, as we ve seen, declarative tasks are easily performed with tags. For example, by using iteration tags we can modify the previous JSP fragment:
| Header | Value |
|---|