You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/06/08 02:44:14 UTC
svn commit: r1133221 - in /tomcat/trunk:
java/org/apache/catalina/deploy/WebXml.java
java/org/apache/catalina/startup/ContextConfig.java
webapps/docs/changelog.xml
Author: markt
Date: Wed Jun 8 00:44:14 2011
New Revision: 1133221
URL: http://svn.apache.org/viewvc?rev=1133221&view=rev
Log:
Fix regression in welcome file processing
Modified:
tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java?rev=1133221&r1=1133220&r2=1133221&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java Wed Jun 8 00:44:14 2011
@@ -346,13 +346,25 @@ public class WebXml {
}
public Map<String,String> getMimeMappings() { return mimeMappings; }
- // welcome-file-list
- // When merging web.xml files it may be necessary for any new welcome files
- // to completely replace the current set
+ // welcome-file-list merge control
private boolean replaceWelcomeFiles = false;
+ private boolean alwaysAddWelcomeFiles = true;
+ /**
+ * When merging/parsing web.xml files into this web.xml should the current
+ * set be completely replaced?
+ */
public void setReplaceWelcomeFiles(boolean replaceWelcomeFiles) {
this.replaceWelcomeFiles = replaceWelcomeFiles;
}
+ /**
+ * When merging from this web.xml, should the welcome files be added to the
+ * target web.xml even if it already contains welcome file definitions.
+ */
+ public void setAlwaysAddWelcomeFiles(boolean alwaysAddWelcomeFiles) {
+ this.alwaysAddWelcomeFiles = alwaysAddWelcomeFiles;
+ }
+
+ // welcome-file-list
private Set<String> welcomeFiles = new LinkedHashSet<String>();
public void addWelcomeFile(String welcomeFile) {
if (replaceWelcomeFiles) {
@@ -1322,7 +1334,16 @@ public class WebXml {
// Context doesn't use version directly
for (String welcomeFile : welcomeFiles) {
- context.addWelcomeFile(welcomeFile);
+ /*
+ * The following will result in a welcome file of "" so don't add
+ * that to the context
+ * <welcome-file-list>
+ * <welcome-file/>
+ * </welcome-file-list>
+ */
+ if (welcomeFile != null && welcomeFile.length() > 0) {
+ context.addWelcomeFile(welcomeFile);
+ }
}
// Do this last as it depends on servlets
@@ -1848,9 +1869,10 @@ public class WebXml {
taglibs.putAll(temp.getTaglibs());
for (WebXml fragment : fragments) {
- for (String welcomeFile : fragment.getWelcomeFiles()) {
- // Always additive
- addWelcomeFile(welcomeFile);
+ if (fragment.alwaysAddWelcomeFiles || welcomeFiles.size() == 0) {
+ for (String welcomeFile : fragment.getWelcomeFiles()) {
+ addWelcomeFile(welcomeFile);
+ }
}
}
Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1133221&r1=1133220&r2=1133221&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Wed Jun 8 00:44:14 2011
@@ -1199,6 +1199,9 @@ public class ContextConfig
// distributable when the default fragment is merged with the main
// web.xml
webXmlDefaultFragment.setDistributable(true);
+ // When merging, the default welcome files are only used if the app has
+ // not defined any welcomes files.
+ webXmlDefaultFragment.setAlwaysAddWelcomeFiles(false);
// Parse global web.xml if present
InputSource globalWebXml = getGlobalWebXmlSource();
@@ -1211,7 +1214,7 @@ public class ContextConfig
// Parse host level web.xml if present
// Additive apart from welcome pages
- webXml.setReplaceWelcomeFiles(true);
+ webXmlDefaultFragment.setReplaceWelcomeFiles(true);
InputSource hostWebXml = getHostWebXmlSource();
parseWebXml(hostWebXml, webXmlDefaultFragment, false);
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1133221&r1=1133220&r2=1133221&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 8 00:44:14 2011
@@ -60,6 +60,10 @@
web application from being marked as distributable. (kfujino/mark)
</fix>
<fix>
+ Correct a regression in the fix for <bug>51278</bug> that prevented a
+ web application from overriding the default welcome files. (mark)
+ </fix>
+ <fix>
Enable remaining valves for Servlet 3 asynchronous processing support.
(markt)
</fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org