From: markt Date: Fri, 10 Jul 2009 15:53:59 +0000 (+0000) Subject: Correct location of taglib element varies with spec version. WebRuleSet was using... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0087faf2ce828490a2120eaf0271c6707fba81f9;p=tomcat7.0 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. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@792996 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/startup/WebRuleSet.java b/java/org/apache/catalina/startup/WebRuleSet.java index 951b79a62..9bc7d55bc 100644 --- a/java/org/apache/catalina/startup/WebRuleSet.java +++ b/java/org/apache/catalina/startup/WebRuleSet.java @@ -301,11 +301,20 @@ public class WebRuleSet extends RuleSetBase { 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 @@ final class ServiceQnameRule extends Rule { 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