Deploying Tag Libraries
See Also
To use a tag library that contains class-based tag handlers,
you must first package it
as a JAR file. This topic shows how to use the IDE to
package a class-based tag library. Because the IDE does not
yet support JSP 2.0 TLD files, you cannot use this
procedure to package tag files.
To package a class-based tag library as a JAR file:
- In the Filesystems window, right-click the tag library descriptor's (TLD)
node.
- From the contextual menu, choose Create Tag Library JAR. This action creates
a JAR recipe node in the web module's root directory.
- (Optional) Right-click the JAR recipe node and choose Properties from
the contextual menu. Use the File Filter property to exclude files
from the JAR file.
- (Optional) Expand the JAR recipe node, right-click the Contents node, and
choose Properties from the contextual menu. Click the ellipsis (...) button
to display a Content dialog box that enables you to add other files to the
JAR recipe.
- Right-click the JAR recipe node and choose Compile from the contextual
menu to create the JAR file.
You can deploy a class-based tag library to a web module in three ways:
- By testing the tag library in place, in other words,
by keeping the TLD file in the WEB-INF
directory, and by placing tag handler classes in packages under the WEB-INF/Classes
directory. The tag library is not actually packaged, but you can make changes
to the handler classes and customizers and see immediate results. This method
is convenient for testing your tag library as you develop it.
- By adding the JAR file to a web module from the filesystem. You can also add
a tag library to the tag library repository.
- By cutting and pasting the JAR File into the appropriate
WEB-INF/lib directory.
 |
Situations exist on Windows platforms in which
you might not be able to paste the JAR file into the
WEB-INF/lib directory, for example, when a
JAR with the same name exists, and it is currently being used by the
server. |
With JSP 1.2, you no longer need to configure the deployment descriptor (web.xml)
to specify the location of the tag library. A JSP 1.2 compliant server searches
all the TLD files under WEB-INF and all the TLD files that are packaged
in JAR files in the WEB-INF/lib directory for a matching URI.
To test a tag library in place:
- If the tag library is not already in a web module, convert the filesystem
containing the tag library into a web module using Tools
Convert Filesystem
into Web Module. Leave the TLD file and the
Java tag handler classes in place.
- Create a JSP file.
- Add a taglib directive with uri and prefix attributes to the JSP file. For example:
<%@ taglib prefix="sql"
uri="http://java.sun.com/jstl/ea/sql" %>
- Add code to the JSP file to test the tags.
- Execute the JSP file.
To cut and paste the JAR File:
- In the Filesystems window, right-click the JAR file to be cut.
- From the contextual menu, choose Copy or Cut.
- Right-click the WEB-INF/lib directory into which you want to paste
the JAR file.
- From the contextual menu, choose Paste.
Legal Notices