jetty.project
jetty.project copied to clipboard
Review DefaultServlet behaviours for including and pathInfoOnly
Jetty version(s) jetty-12
Jetty Environment ee10, but probably ee9//8 as well
Questions to resolve via a review of DefaultServlet behaviour:
- if a welcome servlet is being served via an
include, why do we use theservletPathfrom the request, rather than just thepathInfo(as is the case when not being included): see https://github.com/eclipse/jetty.project/blob/jetty-12.0.x/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/DefaultServlet.java#L638 Given:
_contextHandler = new ServletContextHandler();
_contextHandler.setContextPath("/context");
_contextHandler.setBaseResourceAsPath("/some/path/contextResources");
_contextHandler.setWelcomeFiles(new String[] {"index.x"});
ServletHolder rHolder = _contextHandler.addServlet(DefaultServlet.class, "/r/*");
rHolder.setInitParameter("welcomeServlets", "true");
_contextHandler.addServlet(RogerThatServlet.class, "*.x");
The request /context/r/ is dispatched to /index.x, which is handled by the RogerThatServlet as expected.
However, a request such as /context/dispatch?include=/r/ - where we do an include dispatch to the DefaultServlet with /r/ - results in trying to find a servlet that matches /r/index.x. That will be the same servlet (see line 641) and we don't handle the welcome.
- why do we use the
getEncodedPathInContext()method inDefaultServlet.doGet()to calculate which resource to service, but yet that value is then ignored when we need to serve a welcome servlet, and we use thegetPathInfo()from the request instead?
@gregw does your latest PR for the ResourceServlet address this?
I don't think this is an issue.
The servlet mapping for "/r/*" has precedence over "*.x", so the welcome servlet matches itself.
@lorban @janbartel thoughts?
@janbartel I'm going to close this unless you have any thoughts to the contrary?