https://bz.apache.org/bugzilla/show_bug.cgi?id=64109

            Bug ID: 64109
           Summary: Bad handling of special "" URI mapping rule
           Product: Tomcat 9
           Version: 9.0.30
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Servlet
          Assignee: dev@tomcat.apache.org
          Reporter: gr.grzy...@gmail.com
  Target Milestone: -----

I'm checking Servlet 4 specification, 12.2, "Specification of Mappings" chapter
(when working on Pax Web).

I know this rule is a bit confusing:

> The empty string ("") is a special URL pattern that exactly maps to the
> application's context root, i.e., requests of the form
> http://host:port/<context-root>/. In this case the path info
> is "/" and the servlet path and context path is empty string ("").

But I see that `org.apache.catalina.mapper.Mapper#internalMapExactWrapper()`
works fine - even if I have "/c1" context and "" path mapped to some servlet,
`internalMapExactWrapper()` sets proper values:

    // Special handling for Context Root mapped servlet
    mappingData.pathInfo.setString("/");
    mappingData.wrapperPath.setString("");
    // This seems wrong but it is what the spec says...
    mappingData.contextPath.setString("");

However, inside actual servlet,
`org.apache.catalina.connector.Request#getContextPath()` returns "/c1" as
context path even if underlying
org.apache.catalina.connector.Request#mappingData contains proper (though
confusing according to specification) values.

Is this intended? It could be that JavaDoc for
`javax.servlet.http.HttpServletRequest#getContextPath()` is _better_ and just
says nothing about the special mapping rule from specification chapter 12.2...

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to