This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new f2a7c73e9f Ensure application configured welcome files override the 
defaults
f2a7c73e9f is described below

commit f2a7c73e9fbf5d074d8a0d9ee1b0d1b485eb4152
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 12 12:01:38 2025 +0100

    Ensure application configured welcome files override the defaults
    
    Also fix a typo and remove a completed TODO
---
 java/org/apache/catalina/startup/Tomcat.java | 7 +++++--
 webapps/docs/changelog.xml                   | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/startup/Tomcat.java 
b/java/org/apache/catalina/startup/Tomcat.java
index be4e4a4291..716ed2b4ae 100644
--- a/java/org/apache/catalina/startup/Tomcat.java
+++ b/java/org/apache/catalina/startup/Tomcat.java
@@ -992,7 +992,6 @@ public class Tomcat {
      * <li>MIME mappings (subset of those in conf/web.xml)</li>
      * <li>Welcome files</li>
      * </ul>
-     * TODO: Align the MIME mappings with conf/web.xml - possibly via a common 
file.
      *
      * @param contextPath The path of the context to set the defaults for
      */
@@ -1034,11 +1033,15 @@ public class Tomcat {
         ctx.addWelcomeFile("index.html");
         ctx.addWelcomeFile("index.htm");
         ctx.addWelcomeFile("index.jsp");
+        // Any application configured welcome files should override the 
defaults.
+        if (ctx instanceof StandardContext stdCtx) {
+            stdCtx.setReplaceWelcomeFiles(true);
+        }
     }
 
 
     /**
-     * Add the default MIME type mappings to the provide Context.
+     * Add the default MIME type mappings to the provided Context.
      *
      * @param context The web application to which the default MIME type 
mappings should be added.
      */
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 00ef06c51e..ef55820e92 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -166,6 +166,10 @@
         path. (markt)
       </scode>
       <!-- Entries for backport and removal before 12.0.0-M1 below this line 
-->
+      <fix>
+        Ensure application configured welcome files override the defaults when
+        configuring an embedded web application programmatically. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to