background image

Including the Tag Library Implementation

<< Tag Library Descriptor | Reusing Content in JSP Pages >>
<< Tag Library Descriptor | Reusing Content in JSP Pages >>

Including the Tag Library Implementation

To learn how to configure the example, refer to the deployment descriptor, which includes the
following configurations:
A display-name element that specifies the name that tools use to identify the application.
Nested inside a jsp-config element is a taglib element, which provides information on a
tag library used by the pages of the application. Inside the taglib element are the
taglib-uri
element and the taglib-location element. The taglib-uri element identifies
the logical name of the tag library. The taglib-location element gives the absolute
location or the absolute URI of the tag library.
The absolute URIs for the JSTL library are as follows:
Core
:
http://java.sun.com/jsp/jstl/core
XML
:
http://java.sun.com/jsp/jstl/xml
Internationalization
:
http://java.sun.com/jsp/jstl/fmt
SQL
:
http://java.sun.com/jsp/jstl/sql
Functions
:
http://java.sun.com/jsp/jstl/functions
When you reference a tag library with an absolute URI that exactly matches the URI declared in
the taglib element of the TLD (see
"Tag Library Descriptors" on page 247
), you do not have to
add the taglib element to web.xml; the JSP container automatically locates the TLD inside the
JSTL library implementation.
Including the Tag Library Implementation
In addition to declaring the tag library, you also must make the tag library implementation
available to the web application. There are several ways to do this. Tag library implementations
can be included in a WAR in an unpacked format: Tag files are packaged in the /WEB-INF/tag/
directory, and tag handler classes are packaged in the /WEB-INF/classes/ directory of the
WAR. Tag libraries already packaged into a JAR file are included in the /WEB-INF/lib/
directory of the WAR. Finally, an application server can load a tag library into all the web
applications running on the server. For example, in the Application Server, the JSTL TLDs and
libraries are distributed in the archive appserv-jstl.jar in as-install/lib/. This library is
automatically loaded into the classpath of all web applications running on the Application
Server, so you don't need to add it to your web application.
The iterator tag library is implemented with tag handlers. Therefore, its implementation
classes are packaged in the /WEB-INF/classes/ directory.
Using Custom Tags
The Java EE 5 Tutorial · September 2007
174