Skip to content

Fix #20 - add support for <welcome-servlet> #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

markt-asf
Copy link
Contributor

Implements the solution discussed in #20.

I plan on leaving this open for a week or two for discussion before merging and wouldn't be surprised if changes were required.

@markt-asf
Copy link
Contributor Author

markt-asf commented Jun 25, 2025

Re-based and made a couple clarifications to the specification text. No functional change.

@markt-asf
Copy link
Contributor Author

Some feedback from the Tomcat community:

At the moment, a <welcome-servlet> is almost certain to match since it will likely be using extension mapping making any welcome resources that follow unnecessary. This might be an issue for web fragments since any welcome resources defined in a fragment will be added to the end of the existing list of welcome resources.

Is this a problem? I think probably yes, but would welcome additional views. If it is an issue, then one way to resolve it would be to change the mapping algorithm to:

For each welcome resource in the order it appears in the deployment descriptor:

  • append the partial URI to the request URI to create a welcome URI
  • if the welcome URI has an exact match to a servlet mapping, send the request to that servlet
  • if the welcome URI has a prefix match to a servlet mapping, send the request to that servlet
  • if a static file exists in the web application for the welcome URI, send the request to that static resource

If no match is found then for each legacy welcome file and welcome-servlet in the order they appear in the deployment descriptor:

  • append the partial URI to the request URI to create a welcome URI
  • if a servlet mapping (other than the default servlet) matches the welcome URI, send the request to that servlet

This does mean two passes of the welcome files are more likely but I think it is closer to the current behaviour whilst fixing the problem this change was intended to fix. I'm currently leaning towards this alternative approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant