Author: markt
Date: Fri Jul 10 15:53:59 2009
New Revision: 792996
URL: http://svn.apache.org/viewvc?rev=792996&view=rev
Log:
Correct location of taglib element varies with spec version. WebRuleSet was
using 2.3 and earlier location. Update it to a) support 2.4 and later as well
as 2.3 and earlier b) complain if taglib definition location is not consistent
with declared spec version.
Modified:
tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java
Modified: tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java?rev=792996&r1=792995&r2=792996&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebRuleSet.java Fri Jul 10
15:53:59 2009
@@ -301,11 +301,20 @@
new Class[] { Integer.TYPE });
digester.addCallParam(prefix +
"web-app/session-config/session-timeout", 0);
+ // Taglibs pre Servlet 2.4
+ digester.addRule(prefix + "web-app/taglib", new
TaglibLocationRule(false));
digester.addCallMethod(prefix + "web-app/taglib",
"addTaglib", 2);
digester.addCallParam(prefix + "web-app/taglib/taglib-location", 1);
digester.addCallParam(prefix + "web-app/taglib/taglib-uri", 0);
+ // Taglibs Servlet 2.4 onwards
+ digester.addRule(prefix + "web-app/jsp-config/taglib", new
TaglibLocationRule(true));
+ digester.addCallMethod(prefix + "web-app/jsp-config/taglib",
+ "addTaglib", 2);
+ digester.addCallParam(prefix +
"web-app/jsp-config/taglib/taglib-location", 1);
+ digester.addCallParam(prefix + "web-app/jsp-config/taglib/taglib-uri",
0);
+
digester.addCallMethod(prefix +
"web-app/welcome-file-list/welcome-file",
"addWelcomeFile", 0);
@@ -925,5 +934,32 @@
contextService.setServiceqnameLocalpart(localpart);
contextService.setServiceqnameNamespaceURI(namespaceuri);
}
+
}
+/**
+ * A rule that checks if the taglib element is in the right place.
+ */
+final class TaglibLocationRule extends Rule {
+
+ final boolean isServlet24OrLater;
+
+ public TaglibLocationRule(boolean isServlet24OrLater) {
+ this.isServlet24OrLater = isServlet24OrLater;
+ }
+
+ @Override
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ Context context = (Context) digester.peek(digester.getCount() - 1);
+ // If we have a public ID, this is not a 2.4 or later webapp
+ boolean havePublicId = (context.getPublicId() != null);
+ // havePublicId and isServlet24OrLater should be mutually exclusive
+ if (havePublicId == isServlet24OrLater) {
+ throw new IllegalArgumentException(
+ "taglib definition not consistent with specification
version");
+ }
+ }
+
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]