On 01/10/18 12:54, Florent Guillaume wrote: > Hi, > > I'm observing a behavior (Tomcat 9.0.10) with respect to getServletPath() > that I don't understand when reading the servlet spec. > > For a request http://localhost:8080/nuxeo/ui/ I get the following: > > httpRequest.getRequestURL() > http://localhost:8080/nuxeo/ui/ > httpRequest.getRequestURI() > /nuxeo/ui/ > httpRequest.getContextPath() > /nuxeo > httpRequest.getServletPath() > /ui/index.jsp > httpRequest.getPathInfo() > null > httpRequest.getQueryString() > null > > But my understanding from the Servlet spec is that we should always have > (Servlet 4.0 spec, ยง3.5): > requestURI = contextPath + servletPath + pathInfo > which you can see is not the case here. I don't think getServletPath() > should return the index.jsp part, which is a welcome file. > > FYI the mapping that matches the above is: > httpRequest.getHttpServletMapping().getServletName() > (java.lang.String) jsp > httpRequest.getHttpServletMapping().getMappingMatch() > (javax.servlet.http.MappingMatch) EXTENSION > httpRequest.getHttpServletMapping().getPattern() > (java.lang.String) *.jsp > httpRequest.getHttpServletMapping().getMatchValue() > (java.lang.String) ui/index > > Is this a bug in Tomcat or did I miss something from the spec?
It is one of the many grey areas in the spec around those methods. This is currently being tracked as: https://github.com/eclipse-ee4j/servlet-api/issues/18 Once Eclipse has figured out how the spec update process is going to work, I'm expecting work to start on that issue. As an aside, requestURI = contextPath + servletPath + pathInfo is a good general rule but it does not work for all edge cases (which are generally the areas issue 18 seeks to address). Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org