"The following sections are excerpted from various sections and chapters within JSTL: Practical Guide for JSP Programmers. You can find complete details all of the standard actions available in the JSTL, as well as a developer's quick reference guide, provided in the book. The book also has a free download available. The download demonstrates the use of each standard action."
"Before we dive into the various functional areas in the JSTL, we should start with the expression language. This is one of the most important features of the JSTL and is a prominent feature of the JSP 2.0 specification. The expression language (EL) allows for a much simpler syntax for the page author to manipulate application data. Currently the EL in the JSTL can only be used with tag attribute values, primarily in actions that reside in the Core tag library. It is possible to use the EL within template text if you are working with the JSP 2.0 specification. Expressions in template text are not supported if you are using JSTL 1.0 with JSP 1.2."
"JSTL 1.0: What JSP Applications Need, Part 3 -- In the final installment in this series on JSTL Hans Bergsten, author of JavaServer Pages, 2nd Edition, shows you how to leverage the JSTL classes when developing your own custom actions."
"The evolution of Web technologies in Java technology has greatly benefited developers over the years. The latest evolution, the unified expression language, promises to further benefit developers by allowing them to mix both JSTL and JSF technologies. The unified expression language is now an important part of the Java EE 5 specification, which makes it an important part of Geronimo 2.0. Geronimo has once again helped developers by not only implementing the spec, but by using the reference implementation of the spec. With GlassFish JSTL and Geronimo 2.0, developers have more choices than ever when building Java Web applications."
"Because request-time attribute values are specified using expressions, they are prone to the same software maintenance issues as other scripting elements. For this reason, the JSTL custom tags support an alternate mechanism for specifying dynamic attribute values. Rather than using full-blown JSP expressions, attribute values for JSTL actions can be specified using a simplified expression language (EL). The EL provides identifiers, accessors, and operators for retrieving and manipulating data resident in the JSP container. The EL is loosely based on EcmaScript (see Resources) and the XML Path Language (XPath), so its syntax should be familiar to both page designers and programmers. The EL is geared toward looking up objects and their properties, and performing simple operations on them; it is not a programming language, or even a scripting language. When combined with the JSTL tags, however, it enables complex behavior to be represented using a simple and convenient notation. EL expressions are delimited using a leading dollar sign ($) and both leading and trailing braces ({}), as highlighted in Listing 3."
"The remaining <c:forEach> attribute, varStatus, plays the same role whether iterating over integers or collections. Like the var attribute, varStatus is used to create a scoped variable. Instead of storing the current index value or the current element, however, the variable named by the varStatus attribute is assigned an instance of the javax.servlet.jsp.jstl.core.LoopTagStatus class. This class defines a set of properties, listed in Table 2, that describe the current state of an iteration."
"JSTL is actually a collection of custom tag libraries that have been standardized for JSP 1.2. Many of the JSTL tags are analogous to the core JSP tags, although they do much more. For example, the c:import tag is very similar to the include and jsp:include directives we've worked with in the previous installments of this series (see Resources). Like includes, c:import helps you populate the pages of your Web site or Web application, but its functionality extends beyond what the core JSP tags can do."
"So far in our tour of JSTL, we've examined the JSTL expression language (EL) and both the core and fmt tag libraries. In this final installment, we'll consider the sql and xml libraries that -- as their names suggest -- provide custom tags for accessing and manipulating data retrieved from SQL databases and XML documents."
"In the previous articles in this series, we discussed the JSTL and its expression language (EL). We also examined the custom tags defined by the core library. Specifically, in "The expression language" we said the EL provides a simplified language for accessing and manipulating data within a JSP application and making that data available to JSTL custom tags as dynamic attribute values. The core library, which includes custom tags for managing scoped variables, displaying EL values, implementing iterative and conditional content, and interacting with URLs, was the topic of "Getting down to the core.""
"Now you know how to make database queries as easy as they should be, using the JSTL 1.1 SQL tag library, Tomcat 5.5, and the Apache Derby relational database. Because the JSTL 1.1 maintenance release requires a JSP container that supports the Servlet 2.4 and JSP 2.0 specifications, you can configure the JSTL libraries in Tomcat 5.5. You've also learned how easy it is to set up an Apache Derby database, schemas, and tables using the Interactive Java (ij) tool. In addition to learning the JDBC drivers used with Tomcat 5.5, you know how to use simple SQL actions for queries, updates, and grouping several operations into a single transaction."
"Define a custom tag for table display and make your Web applications easier to manage. You'll reduce the overhead of writing the same piece of code multiple times because you update the code in only one place. The Tag class reflects your changes across all JSP pages. Here, I'll explain how to create a custom tag for table display that is flexible enough to handle different HTML controls, such as href, checkbox, radio button, text field, and combo box."
"The JSP Standard Template Library (JSTL) is a very new component released by Sun for JSP programming. JSTL allows you to program your JSP pages using tags, rather than the scriptlet code that most JSP programmers are already accustomed to. JSTL can do nearly everything that regular JSP scriptlet code can do. You may be wondering why we need yet another HTML generation programming language."
"Lines 2-3—these JSP tags are used for using external tag libraries, and to be more exact, to use core and SQL JSTL libraries. We set prefixes for them, so by using these prefixes we will access their functions."
"In this article, I will describe a unique way of using a Java JSP tab library for server-side verification, and briefly describe the creation of JSP tags. The examples will build upon a Web application from my previous article "Applying MVC to web-based applications with JSP views"—a simple project that displays weather information after users submit a ZIP code or city name. The application followed Model-View-Controller (MVC) architecture and used the Tomcat application server."
"Clearly within Java Studio Creator, the emphasis is on component controls and data binding. This allows you to put data-bound pages together very quickly. It is very successful; however, data binding does limit you in some ways. For example, when binding a data grid, you need to know the number of columns ahead of time and provide header information for them. Now, suppose that you have data that you want to display in a grid for a time period that you do not know ahead of time, or maybe you simply have a very large number of columns to display and don't want to create large numbers of pre-defined column details for a grid."
"The idea behind tag libraries in JSP looks very good on paper. Tag libraries allow you to associate Java code to a series of XML-like tags that are packaged as a library. The user of tag libraries (mainly the JSP developer) will use these tags to develop an application. The more complete the tag libraries are, the need to write Java code directly inside the JSP page or via JavaBeans diminishes. Taglibs provide a reusable framework for J2EE application development, but their key to success is availability. The same way we go to repositories to retrieve a particular DTD or XML Schema, we need a repository of taglibs."
"With tag libraries, you can declare a custom tag and then associate some code with it and control when the code is invoked in relation to the opening or closing tags. The key class to make this work is TagSupport, which is part of the javax.servlet.jsp.tagext package. Note that this is not standard Java API. Most likely it will ship with your JSP/servlet engine, like Apache Tomcat."
"There's been a lot of hype, to be sure, surrounding JavaServer Pages tag libraries. Some people get mighty excited at their mere mention. But JSP taglibs really are one of those rare software ideas that are incredibly both easy to grasp and use for both the hardened back-end Java developer and HTML-guru Web page producer."
"To illustrate the JSTL expression language, this chapter uses a number of JSTL actions, such as <c:out>, <c:if>, and <c:forEach>, that have not yet been formally discussed in this book. However, the use of those actions is intuitive and this chapter does not use any of those action's advanced features. See Chapter 3, "General-Purpose and Conditional Actions," and "Iteration Actions" on page 150 for formal discussions of the actions used throughout this chapter."
"The first article of the "Web Tier to Go With Java EE 5" series summarizes new features in JavaServer Pages (JSP) 2.1 technology. The maintenance release of the Java Standard Tag Library (JSTL) 1.2 also contributes significantly to the Java EE platform."
"JSTL is still in early access release, but that doesn't mean that you shouldn't start paying attention to it. JSTL is being developed under the Java Community Process, in the JSR-052 expert group. The purpose of JSTL is to work towards a common and standard set of custom tags. There are currently many tag libraries available for download from various vendors, as well as from open source projects such as the Jakarta Taglibs project. In fact, a JSP 1.2/Servlet 2.3-compliant reference implementation of JSTL is being hosted under the Taglibs project. You can run this reference implementation under Tomcat, but you'll need to use Tomcat 4."
"Custom tag libraries allow the Java programmer to write code that provides data access and other services, and they make those features available to the JSP author in a simple to use XML-like fashion. An action in a web application -- for example, gaining database access -- can be customized by using a custom tag in a JSP page. The JSP author doesn't have to understand the underlying detail to complete the action. In short, a tag library is a collection of custom actions presented as tags."
"In this article, the second in the JSP custom tag libraries series, we will cover advanced JSP features and how to use them. If you aren't familiar with tag libraries, spend a few minutes reading the previous article, Designing JSP Custom Tag Libraries."
"Why not use Jakarta Velocity as is? Because it's not JSP. So if you have a mandate to use JSP, Velocity by itself isn't a solution. Why not use the Velocity Tag Library? While this approach gives direct access to Velocity's macros, it doesn't solve many of our problems. First, it's no better than JSP in exposing business logic to an HTML author. Second, it doesn't provide any sort of interpage reusability like JSP taglibs do, other than <jsp:include .../>. Third, it doesn't provide any sort of type checking for the HTML author."
"While the Java programming language has built-in support to create basic menu structures, JSP lacks support. Web applications must use either Java applets or JavaScript to implement menu structures. Many web application developers prefer JavaScript to applets for simplicity and ease of deployment. This article describes a custom tag library that simplifies the process of generating JavaScript dynamically. The design and implementation of the tag library are covered in detail."
"This article is the second in a series on JSTL, the JSP Standard Tag Library. If you need a primer as to what JSTL encompasses, check out part one of this series."
"Following on from the first article, this article shows how to start building tests with TagUnit. Tests are written as JSP pages and by using the various assertion tags, complex test cases and test suites can be built up. In conjunction with other testing tools, TagUnit provides a way to help test more of your J2EE web applications. With TagUnit, custom tags can be tested in the same way that page authors will use them--from JSP pages."
"Introduction to Tag Unit, Part 2 JSP custom tags have been adopted by JSP developers as a way of abstracting complex code out of the page and into reusable components. This article introduces TagUnit--an easy-to-use tool that makes it possible to comprehensively test JSP tags."
"Easy Custom Tags with Tag Files, Part 1 Tag Files in JSP 2.0 make creating custom tags much easier, automating away previous annoyances like manually compiling and writing descriptors. Budi Kurniawan offers an introduction to creating and using tag files."
"Easy Custom Tags with Tag Files, Part 2 In part two of his series on JSP Tag Files, Budi Kurniawan continues his coverage of this hassle-reducing technology. This week he looks at variables, jsp:doBody, jsp:invoke, and how to package your tag files in a jar file."
"The JavaServer Pages Standard Tag Library (JSTL) satisfies the demand for a set of standard JSP custom tags to handle common tasks needed by all JSP pages, including conditional processing, XML processing, internationalization, and database access. As you can see from this article, JSTL is easy to work with, and its reusable standard custom tags lead to faster development of web applications."
"This paper explores the possibilities of combining these two technologies and creating a web deployable email application that uses the JavaMail API and custom JSP tag libraries for presentation. JSP pages are intended to provide a "declarative, presentation-centric method of developing servlets." An ideal JSP does not contain any inline code or scriptlets. Instead, the functionality and business logic is executed in tags which are either predefined in the API or in custom tag libraries. The Email Web Application (EWA) presented in this paper uses a custom tag library. The tags are implemented using the JavaMail API."
"The value of scriptless means that the tag body is allowed to have JSP content as long as it doesn't contain any scripting elements like <% ... %> or <%= ... %>. If present, the body of the tag would be processed just like any other JSP content."