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:

  1. In the Filesystems window, right-click the tag library descriptor's (TLD) node.
  2. From the contextual menu, choose Create Tag Library JAR. This action creates a JAR recipe node in the web module's root directory.
  3. (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.
  4. (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.
  5. 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:

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:

  1. If the tag library is not already in a web module, convert the filesystem containing the tag library into a web module using Tools and choose Convert Filesystem into Web Module. Leave the TLD file and the Java tag handler classes in place.
  2. Create a JSP file.
  3. 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" %>
  4. Add code to the JSP file to test the tags.
  5. Execute the JSP file.

To cut and paste the JAR File:

  1. In the Filesystems window, right-click the JAR file to be cut.
  2. From the contextual menu, choose Copy or Cut.
  3. Right-click the WEB-INF/lib directory into which you want to paste the JAR file.
  4. From the contextual menu, choose Paste.
See Also
Using Tag Libraries
Adding a Tag Library from the Filesystem
Using Tags in JSP Files
About Tag Libraries
About Web Modules

Legal Notices