-
Bug
-
Resolution: Done
-
Major
-
None
-
None
Given a request to / and a welcome file set to /index
JBossWeb wil return "/" when HttpServletRequest#getRequestURI is called,
and "/index" when HttpServletRequest#getServletPath is called.
Undertow will return "/index" in both cases.
It's clear what happens by looking at ServletInitialHandler#handleRequest
which does a full rewrite for welcome files:
exchange.setRelativePath(exchange.getRelativePath() + info.getRewriteLocation()); exchange.setRequestURI(exchange.getRequestURI() + info.getRewriteLocation()); exchange.setRequestPath(exchange.getRequestPath() + info.getRewriteLocation());
The Servlet spec (10.10) does seem to justify this somewhat by saying the
following:
The container may send the request to the welcome resource with a forward, a redirect, or a container specific mechanism that is indistinguishable from a direct request.
However, the JavaDoc for HttpServletRequest#getRequestURI doesn't seem to allow this.
Example:
With a welcome file declaration in web.xml as follows:
<welcome-file-list> <welcome-file>index</welcome-file> </welcome-file-list>
and when requesting the context root of an application (e.g. http://localhost:8080 for a root deployment), the results are as follows:
getRequestURI | getServletPath | |
---|---|---|
Tomcat/JBossWeb | / | /welcome |
Undertow | /welcome | /welcome |