Packaging and Deploying a Custom Tag Library
See Also
To deploy a tag library for use in a web module, you must first package it
as a JAR file.
To package a tag library as a JAR file:
- In the Explorer, right-click the tag library descriptor to be packaged.
- From the contextual menu, choose Create Tag Library JAR. This action creates
a file with a .jar extension. It also creates an associated jarContent
file, also called a recipe file, which can be used to add additional classes
or packages to the library.
You can deploy a custom tag library in three ways:
- By testing the tag library in place, in other words,
by keeping the
.tld
file available 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 and modifying the Taglib element in
the deployment descriptor so that it maps to the JAR file containing the desired
tag library.
 |
Situations exist on Windows platforms in which
you might not be able to paste your taglib JAR file into the
WEB-INF/lib directory, for example, when a taglib
JAR with the same name exists, and it is currently being used by the
server. If you encounter this problem, refer to the release notes. |
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 generated and compiled
Java tag handler classes in place.
- Modify the Taglib element in the deployment descriptor to /<yourTagLib>.tld.
- Create a JSP, and add references to your new tags.
- Execute your JSP.
To modify the Taglib element in the deployment descriptor:
- Click the Deployment tab of the
web.xml
property sheet.
- Click the Tag Libraries value field, and click the ellipses (...) button.
- In the Tag Libraries property editor, select the tag library you want to
modify, and click Edit.
- Edit the Taglib URI and/or Taglib Location and click OK.
- Click OK in the Tag Libraries property editor when you are finished modifying
tag libraries.
To cut and paste the JAR File:
- In the Explorer, 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.
Next, modify the Taglib element in the deployment descriptor so that
it maps to the JAR file containing the desired tag library. This procedure is
not always necessary. In some cases, the IDE adds the Taglib element
automatically.
For more information about deploying custom tag libraries, see the Building
Web Components Programming Guide, available from the Sun ONE Studio Developer
Resources page at http://forte.sun.com/ffj/documentation
.
Legal Notices