JavaServer Page

March 11, 2007

Iterating With Tags This is obviously quite an

Filed under: JSP Tag Libraries — webmaster @ 11:29 am

Iterating With Tags ” property=”header” index=”< %= name %>“/>

This is obviously quite an improvement. Why should we bother creating special iteration tags when a two-line scriptlet hardly seems demanding for a Java developer? Again, we can t forget that the goal of building custom tag libraries is to make it possible for non-Java developers (presentation/HTML developers) to build complex sites. Though iteration using scriptlets may not be complex for the Java programmer, it does require the JSP developer to: Know how to iterate on different Java types Enumerations, Iterators, arrays, and so forth. To further complicate the situation, iteration methods usually return an Object that the JSP developer will have to cast. Position the curly brackets in the correct location. If the JSP developer forgets a curly bracket, the JSP compilation will fail, usually with a relatively obscure error message. Maintain and debug yet another portion of Java code. As a result, iteration tags are necessary to enhance the effectiveness of our JavaBean tags and to keep our JSPs scriptlet-free. This chapter explores iteration with tags and shows how to build JSP custom tags that perform iteration for us. We ll start with a brief introduction to iterating with custom JSP tags and discuss their design principles; later, we will develop iteration tags to handle cases in which we wish to iterate over Java s common object containers. NOTE In this chapter, you will see the word iterator used in two distinct ways. When we use the generic term, we mean any multivalued object (be it an Array, an implementation of the java.util.Enumeration interface or an implementation of the java.util.Iterator interface). When we mention Iterator we are speaking strictly about the Java interface.

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

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