JavaServer Page

March 11, 2007

10 Iterating with tags In this chapter

Filed under: JSP Tag Libraries — webmaster @ 5:32 am

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.

” property=”header” index=”< %= name %>“/>

< % } %>

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:

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

Header Value

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Java Web Hosting