InputSource contextWebXml = getContextWebXmlSource();
parseWebXml(contextWebXml, webXml, false);
- if (!webXml.isMetadataComplete()) {
+ // Assuming 0 is safe for what is required in this case
+ double webXmlVersion = 0;
+ if (webXml.getVersion() != null) {
+ webXmlVersion = Double.parseDouble(webXml.getVersion());
+ }
+
+ if (webXmlVersion >= 3 && !webXml.isMetadataComplete()) {
// Process /WEB-INF/classes for annotations
URL webinfClasses;
try {
// Apply merged web.xml to Context
webXml.configureContext(context);
+
+ // Make the merged web.xml available to other components,
+ // specifically Jasper, to save those components from having to
+ // re-generate it.
+ String mergedWebXml = webXml.toXml();
+ context.getServletContext().setAttribute(
+ org.apache.tomcat.util.scan.Constants.MERGED_WEB_XML,
+ mergedWebXml);
+ if (context.getLogEffectiveWebXml()) {
+ log.info("web.xml:\n" + mergedWebXml);
+ }
} else {
- // Apply merged web.xml to Context
+ // Apply unmerged web.xml to Context
webXml.configureContext(context);
- }
- // Make the merged web.xml available to other components, specifically
- // Jasper, to save those components from having to re-generate it.
- String mergedWebXml = webXml.toXml();
- context.getServletContext().setAttribute(
- org.apache.tomcat.util.scan.Constants.MERGED_WEB_XML,
- mergedWebXml);
- if (context.getLogEffectiveWebXml()) {
- log.info("web.xml:\n" + mergedWebXml);
- }
+ }
}
new SetPublicIdRule("setPublicId"));
digester.addRule(fullPrefix,
new IgnoreAnnotationsRule());
+ digester.addRule(fullPrefix,
+ new VersionRule());
if (fragment) {
// web-fragment.xml
}
/**
+ * A Rule that records the spec version of the web.xml being parsed
+ *
+ */
+
+final class VersionRule extends Rule {
+
+ public VersionRule() {
+ // NO-OP
+ }
+
+ @Override
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ WebXml webxml = (WebXml) digester.peek(digester.getCount() - 1);
+ webxml.setVersion(attributes.getValue("version"));
+
+ if (digester.getLogger().isDebugEnabled()) {
+ digester.getLogger().debug
+ (webxml.getClass().getName() + ".setVersion( " +
+ webxml.getVersion() + ")");
+ }
+ }
+
+}
+
+
+/**
* A rule that logs a warning if absolute ordering is configured.
*/
final class AbsoluteOrderingRule extends Rule {
sb.append("\"http://www.w3.org/2001/XMLSchema-instance\"\n");
sb.append(" xsi:schemaLocation=");
sb.append("\"http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\"\n");
- sb.append(" version=\"3.0\"\n");
+ sb.append(" version=\"");
+ if (version != null) {
+ sb.append(version);
+ } else {
+ // Should be non-null but in case it isn't assume 3.0
+ sb.append("3.0");
+ }
+ sb.append("\"\n");
sb.append(" metadata-complete=\"true\">\n\n");
appendElement(sb, INDENT2, "display-name", displayName);