Ok thanks. I added a workaround in my code for the welcome file case. And indeed I had already observed other situations where requestURI = contextPath + servletPath + pathInfo is not true if there's normalization going on, for instance the fact that we can have:
requestURI = /nuxeo/login.jsp/../foo/bar.xhtml;jsessionid=123 contextPath = /nuxeo servletPath = /foo pathInfo = /bar.xhtml Thanks, Florent On Mon, Oct 1, 2018 at 6:41 PM Mark Thomas <ma...@apache.org> wrote: > 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 > > -- [image: Nuxeo Logo] <https://www.nuxeo.com/> Florent Guillaume Head of R&D [image: LinkedIn] <https://www.linkedin.com/in/fguillaume/> [image: Twitter] <https://twitter.com/efge> [image: Github] <https://github.com/efge> Nuxeo Content Services Platform. Stay ahead.