Recipe 23.1 Downloading the JSTL 1.0 and Using the JSTL Tags in JSPs


You want to download and use the JSTL.


Download the JSTL distribution, in a ZIP or TAR file, from the Apache Jakarta Project.


The Apache Jakarta Project hosts the reference implementation (RI) for the JSTL. An RI is software that is designed to implement a particular Java technology specification in order to demonstrate how the software is intended to function. RIs are freely available for use by software vendors and developers. You can download the binary or source distribution of the JSTL from taglibs /doc/standard-doc/intro.html.

Unpack the ZIP or TAR file into the directory of your choice. This creates a jakarta-taglibs directory.

This recipe uses the Standard Taglib Version 1.0.3, an implementation of the JSTL 1.0. However, by the time you read this, the Jakarta Taglibs site will have introduced Standard Taglib Version 1.1, which is an implementation of the JSTL 1.1. The new version includes some new features such as functions, which are described in Recipe 23.14.

Inside the standard-1.0.3 directory is a lib subdirectory. This directory contains a number of JAR files, including jstl.jar and standard.jar . The jstl.jar contains the JSTL 1.0 API classes; standard.jar is a collection of JSTL 1.0 implementation classes. Add all of the JAR files found in your JSTL distribution's lib directory ( jakarta-taglibs/standard-1.0.3/lib in the example) to WEB-INF/lib .

JSTL 1.1 only requires the installation of jstl.jar and standard.jar in /WEB-INF/lib if you are using J2SE 1.4.2 or higher (as well as Servlet 2.4 and JSP 2.0).

Table 23-1 describes each of the JAR files found in the distribution's lib directory ( courtesy of the Standard Taglib 1.0 documentation).

Table 23-1. Contents of the JSTL 1.0 reference implementation lib directory

File name



JSTL1.0 API classes

standard .jar

JSTL1.0 implementation classes


Xpath engine classes


Java Database Connectivity (JDBC) implementation classes (also included with J2SE 1.4)


Simple API for Xpath parsing


Apache Xalan Extensible StyleSheet Transformations (XSLT) processor

dom.jar, jaxp-api.jar, sax.jar, xercesImpl.jar

Java API for XML Processing (JAXP) 1.2 API libraries

In the JSP where you want to use the JSTL tags, use the proper taglib directive shown in Table 23-2. For example, if you use all of the different JSTL functions ( core , XML, formatting, and SQL), your JSP contains all of the following taglib directives, preferably at the top of the JSP page (they must appear before the tags are used).

Table 23-2. The taglib directives for different JSTL functions, version 1.0

JSTL library

taglib directive


<%@ taglib uri="" prefix="c" %>

XML processing

<%@ taglib uri="" prefix="x" %>

Formatting data (such as dates and currencies) for international users

<%@ taglib uri="" prefix="fmt" %>

SQL and Database access

<%@ taglib uri="" prefix="sql" %>

The Java community is now working on the JSTL Version 1.1, which will require a JSP-2.0 compatible JSP container. JSTL 1.1 will use these different uri values in the taglib directive:

  • , so the entire taglib directive would look like: <%@ taglib uri="" prefix="c" %>

  • , creating a taglib directive of: <%@ taglib uri="" prefix="x" %>

  • , as used in the taglib directive: <%@ taglib uri="" prefix="fmt" %>

  • , creating a taglib directive of: <%@ taglib uri="" prefix="sql" %>

See Also

The Jakarta Project's Taglibs site:; Sun Microsystem's JSTL information page:; Recipe 23.3 on using the core tags; Recipe 23.4 and Recipe 23.5 on using XML- related tags; Recipe 23.6 on using the formatting tags; Recipe 23.7 and Recipe 23.8 on the JSTL's SQL features; Recipe 23.9-Recipe 23.14 on using the EL to access scoped variables , cookies, and JavaBean properties.

Java Servlet & JSP Cookbook
Java Servlet & JSP Cookbook
ISBN: 0596005725
EAN: 2147483647
Year: 2004
Pages: 326 © 2008-2017.
If you may any questions please contact us: