WebSphere -> GlassFish: Migrating extendedDocumentRoot

This entry is based on this GlassFish forum thread

WebSphere v6.1 supports the JSP engine configuration parameter extendedDocumentRoot for sharing JSP files (e.g. tag files) between Web applications. However, extendedDocumentRoot is proprietary and is set in ibm-web-ext.xmi file. There are two ways to migrate extendedDocumentRoot to GlassFish.

Method1: Use a JAR file

Package the tag files into a JAR file. This jar file can then be placed in the WEB-INF/lib directory of each web application. JSP specification requires support for this mechanism and hence is portable across containers. Here is an example to illustrate the steps.

Example

1. Construct jar file - mycustomtags.jar

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

The mytags.tld is required by the JSP specification. 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. Add 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" %>

Method 2: Use alternatedocroot

Another approach is to use alternatedocroot to point to a directory containing the JSP tag files to be shared. For example (based on https://github.com/javaee/glassfish/issues/3210).

<!-- file: sun-web.xml -->
   <sun-web-app>
     <jsp-config>
       <property name="alternatedocroot_1" value="from=/* dir=/tmp/vstest">
         <description>/tmp/vstest</description>
       </property>
     </jsp-config>
   </sun-web-app>

   //Directory /tmp/vstest contains shared JSP tag files
   .
   ./WEB-INF
   ./WEB-INF/tags
   ./WEB-INF/tags/mytag.tag
   ./x.jsp