This document describes how to get up and running quickly with the Standard 1.0 taglib, an implementation of the Java Server Pages Standard Tag Library (JSTL). This document may be useful to page authors and tag developers who are interested in JSTL's functionality. Using the "standard-examples" application is also a great way to familiarize yourself with JSTL's functionality and use.
JSTL is the Java Server Pages Standard Tag Library. It is an effort of the Java Community Process (JCP) and comes out of the JSR-052 expert group.
JSTL encapsulates, as simple tags, core functionality common to many JSP applications. For example, instead of suggesting that you iterate over lists using a scriptlet or different iteration tags from numerous vendors, JSTL defines a standard <forEach> tag that works the same everywhere.
This standardization lets you learn a single tag and use it on multiple JSP containers. Also, when tags are standard, containers can recognize them and optimize their implementations.
JSTL provides support for core iteration and control-flow features, text inclusion, internationalizaton-capable formatting tags, and XML-manipulation tags. It also supports an expression language to simplify page development. Developers may also be interested in JSTL's current extensibility mechanisms; JSTL currently provides a framework for integrating custom tags with JSTL tags.
Please see the Release Notes document for information on any release changes.
The Standard 1.0 taglib uses features provided only by the JSP 1.2 specification, so it requires a JSP 1.2 container. We recommend you test the Standard 1.0 taglib with Tomcat 4.0.
To install Tomcat, follow the instructions at http://jakarta.apache.org/tomcat. To install the Standard 1.0 taglib for use in a web application, follow the instructions at http://jakarta.apache.org/taglibs/binarydist.html. You can also use the "standard-examples" application as a guide.
To use the Standard 1.0 taglib, include the 'jstl.jar' and 'standard.jar' files in your application's WEB-INF/lib directory.
See the Overview Document for information on the constituent tag libraries of Standard 1.0. That document lists the TLD URIs and recommended taglib prefixes.
Using the Standard 1.0 libraries is simple; you simply need to import them into your JSP pages using the taglib directive. For instance, to import the 'core' JSTL library into your page, you would include the following line at the top of your JSP page, as follows:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
Half of JSTL's tags -- the recommended ones -- rely on an expression language. The EL makes it easy for page authors to access and manipulate application data.
For an overview and detailed definition of the default EL see Chapter 3 and Appendix A of the JSTL 1.0 Specification.
Earlier versions of the Standard 1.0 taglib used to let you switch between a number of different expression languages to facilitate experimentation and feecback. Multiple languages are no longer supported since a default EL has been decided upon.
The attributes in tags for the EL version of the library do not accept rtexprvalues. Instead, you specify literal expressions that the tags evaluate at runtime. For example:
<c:forEach items="${page.myItems}" />
As we mentioned above, JSTL includes core tags to support iteration, conditionals, and expression-language support. For more information on precisely how these tags work, you should read the "Functional Description" documents provided as part of this distribution. Here, we just offer a quick roadmap of each feature in order to help orient you.
Developers of custom tags should also read the "Functional Descriptions" provided for each topic addressed by JSTL. JSTL defines some abstract classes that assist with rapid development of tags and promote integration of custom tags with JSTL's tag set.
For instance, custom tags can use JSTL's expression-language mechanism. As another example, extending javax.servlet.jsp.jstl.core.ConditionalTagSupport lets you write a conditional tag by merely implementing a single method that returns a boolean value correspondent with your tag's desired conditional behavior; also, this base class promotes JSTL's recommended model of conditional-tag design.
Similarly, javax.servlet.jsp.jstl.core.IteratorTagSupport lets you easily implement iteration tags. The handlers for the <forEach> and <forTokens> tags extend this class and thus implement the javax.servlet.jsp.jstl.core.IteratorTag interface, which provides a well-defined mechanism for iteration tags to communicate with custom subtags you can write. See the "standard-examples" application for one example of how you might use such custom subtags.