Tutorial: Understanding the New Features of TLD Caching in JSPs
Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.

 

 

Example: Multiple Tag Libraries and TLD Files in a JAR File


This section assumes an example JAR file and presents an example of tag library packaging. This is a situation where multiple tag libraries are packaged in a single JAR file. The JAR file includes tag handler classes, tag-library-validator classes, and TLD files for multiple libraries. The following shows the contents and structure of the example JAR:

examples/BasicTagParent.class
examples/ExampleLoopTag.class
examples/BasicTagChild.class
examples/BasicTagTLV.class
examples/TagElemFilter.class
examples/XMLViewTagTLV.class
examples/TagFilter.class
examples/XMLViewTag.class
META-INF/xmlview.tld
META-INF/exampletag.tld
META-INF/basic.tld
META-INF/MANIFEST.MF

We will specifically cover the following:

Key TLD File Entries for Multiple-Library Example
Key web.xml File Entries for Multiple-Library Example
JSP Page taglib Directives for Multiple-Library Example

Key TLD File Entries for Multiple-Library Example

This section illustrates the <uri> elements of the TLD files.

The basic.tld file includes the following:

<taglib>
 <tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>basic</short-name>
<uri>http://xmlns.oracle.com/j2ee/jsp/tld/demos/basic.tld</uri>
 ...
</taglib>

The exampletag.tld file includes the following:

<taglib xmlns="http://java.sun.com/JSP/TagLibraryDescriptor">
 <tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>example</short-name>
<uri>http://xmlns.oracle.com/j2ee/jsp/tld/demos/exampletag.tld</uri>
...
</taglib>

The xmlview.tld file includes the following:

<taglib>
 <tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>demo</short-name>
<uri>http://xmlns.oracle.com/j2ee/jsp/tld/demos/xmlview.tld</uri>
 ...
</taglib>

Key web.xml File Entries for Multiple-Library Example

This section shows the <taglib> elements of the web.xml deployment descriptor. These map the full URI values, as seen in the <uri> elements of the TLD files in the previous section, to shortcut URI values used in the JSP pages that access these libraries.

...
<taglib>
<taglib-uri>/oraloop</taglib-uri>
<taglib-location>http://xmlns.oracle.com/j2ee/jsp/tld/demos/exampletag.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/orabasic</taglib-uri>
<taglib-location>http://xmlns.oracle.com/j2ee/jsp/tld/demos/basic.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/oraxmlview</taglib-uri>
<taglib-location>http://xmlns.oracle.com/j2ee/jsp/tld/demos/xmlview.tld
</taglib-location>
</taglib>
...

JSP Page taglib Directives for Multiple-Library Example

This section shows the appropriate taglib directives, which reference the shortcut URI values defined in the web.xml elements listed in the preceding section.

The page basic1.jsp includes the following directive:

<%@ taglib prefix="basic" uri="/technology/orabasic" %>

The page exampletag.jsp includes the following directive:

<%@ taglib prefix="example" uri="/technology/oraloop" %>

The page xmlview.jsp includes the following directive:

<%@ taglib prefix="demo" uri="/technology/oraxmlview" %>

Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.


E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy