luehe 2003/07/25 15:39:57
Modified: catalina/src/share/org/apache/catalina/startup
TldConfig.java
Log:
Consider TLDs in WEB-INF subdirectory *and its subdirectories* when
searching for listeners.
The code used to ignore any subdirs of the WEB-INF subdir, claiming
that the JSP spec was not clear about.
The JSP 2.0 spec is clear about it, see JSP.7.3.1:
When deployed directly into a web application, the tag library
descriptor files must always be in the WEB-INF directory, or some
subdirectory of it. TLD files should not be placed in /WEB-INF/classes
or /WEB-INF/lib.
Revision Changes Path
1.13 +28 -15
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/TldConfig.java
Index: TldConfig.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/TldConfig.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TldConfig.java 15 Jun 2003 07:41:12 -0000 1.12
+++ TldConfig.java 25 Jul 2003 22:39:57 -0000 1.13
@@ -623,7 +623,7 @@
DirContext resources = context.getResources();
if (resources != null) {
- tldScanResourcePathsWebInf(resources, resourcePaths);
+ tldScanResourcePathsWebInf(resources, "/WEB-INF", resourcePaths);
tldScanResourcePathsWebInfLibJars(resources, resourcePaths);
}
@@ -633,33 +633,46 @@
}
/*
- * Scans TLDs in the /WEB-INF subdirectory of the web application.
+ * Scans the web application's subdirectory identified by rootPath,
+ * along with its subdirectories, for TLDs.
+ *
+ * Initially, rootPath equals /WEB-INF. The /WEB-INF/classes and
+ * /WEB-INF/lib subdirectories are excluded from the search, as per the
+ * JSP 2.0 spec.
*
* @param resources The web application's resources
- * @param resourcePaths The set of resource paths to add to
+ * @param rootPath The path whose subdirectories are to be searched for
+ * TLDs
+ * @param tldPaths The set of TLD resource paths to add to
*/
private void tldScanResourcePathsWebInf(DirContext resources,
- Set resourcePaths)
+ String rootPath,
+ Set tldPaths)
throws IOException {
-
+
if (log.isTraceEnabled()) {
- log.trace(" Scanning TLDs in /WEB-INF subdirectory");
+ log.trace(" Scanning TLDs in " + rootPath + " subdirectory");
}
try {
- NamingEnumeration items = resources.list("/WEB-INF");
+ NamingEnumeration items = resources.list(rootPath);
while (items.hasMoreElements()) {
NameClassPair item = (NameClassPair) items.nextElement();
- String resourcePath = "/WEB-INF/" + item.getName();
- // FIXME - JSP 2.0 is not explicit about whether we should
- // scan subdirectories of /WEB-INF for TLDs also
- if (!resourcePath.endsWith(".tld")) {
+ String resourcePath = rootPath + "/" + item.getName();
+ if (!resourcePath.endsWith(".tld")
+ && (resourcePath.startsWith("/WEB-INF/classes")
+ || resourcePath.startsWith("/WEB-INF/lib"))) {
continue;
}
- if (log.isTraceEnabled()) {
- log.trace(" Adding path '" + resourcePath + "'");
- }
- resourcePaths.add(resourcePath);
+ if (resourcePath.endsWith(".tld")) {
+ if (log.isTraceEnabled()) {
+ log.trace(" Adding path '" + resourcePath + "'");
+ }
+ tldPaths.add(resourcePath);
+ } else {
+ tldScanResourcePathsWebInf(resources, resourcePath,
+ tldPaths);
+ }
}
} catch (NamingException e) {
; // Silent catch: it's valid that no /WEB-INF directory exists
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]