users@glassfish.java.net

Re: Sharing tag files between web apps

From: <glassfish_at_javadesktop.org>
Date: Fri, 20 Jun 2008 05:14:11 PDT

It is not clear how alternate docroots can be used for sharing of tag files. So here is another possible approach for sharing tag files.

Note that JSP spec defines two different locations for tag files:
a. in the WEB-INF/tags directory (as you noted).
b. package in a jar file that can be placed in WEB-INF/lib directory. This allows tags to be reused across web applications and portable across containers.

JSP spec describes how to package tags in a jar but to illustrate here are the steps:

1. Construct a jar file mycustomtags.jar as follows.

   META-INF/
       mytags.tld
       tags/
           foo.tag
           bar.tag

   The mytags.tld is required by the JSP spec. mytags.tld describes each of the tags
   using a <tag-file> element for each tag file. The <tag-file> contains a sub element
   <path>. The value of <path> element must begin with META-INF/tags.

2. Place mycustomtags.jar in WEB-INF/lib directory of each web application.

3. Use taglib directive with uri attribute to reference the jar file.
   <%@ taglib prefix="t" uri="mycustomtags" %>
[Message sent by forum member 'sekhar' (sekhar)]

http://forums.java.net/jive/thread.jspa?messageID=281587