As mentioned earlier, JSTL includes tags that fit into four areas, each of which is exposed via its own tag library descriptors (TLDs). To use a tag, its corresponding library must be referenced in the JSP. For example, to use the JSTL XML tags in a JSP page, the following taglib directive should be included before the tag is used:
As a result of this relative directive, when the JSP is compiled into a servlet, the container will look for the URI in the Web application's WEB-INF file and its corresponding tag library descriptor.
<taglib> <taglib-uri>/jstl-x</taglib-uri> <taglib-location>/WEB-INF/x.tld</taglib-location> </taglib>
Alternatively, the JSP can follow the absolute declaration, where the library is referenced by its absolute namespace, in which case the container will resolve this to the appropriate tag library:
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
You must have the descriptor (e.g., the x.tld file) and JSTL implementation classes available to the Web application that uses these tags. The TLD and JAR files are packaged with the Java WSDP reference implementation of JSTL. (The JSTL TLD files are in <JWSDP_HOME>/tools/jstl/tlds and the JAR files are in <JWSDP_HOME>/tools/jstl/standard/lib/standard.jar and
<JWSDP_HOME>/tools/jstl/jstl.jar). Table B.2 summarizes details of the different actions; Table B.3 gives the absolute URIs for JSTL tags.
Tag area |
Absolute URI in JSP taglib directive |
---|---|
Core | |
XML | |
Internationalization | |
SQL |