https://issues.apache.org/bugzilla/show_bug.cgi?id=50026

--- Comment #3 from Chuck Caldarale <chuck.caldar...@unisys.com> 2010-09-29 
12:34:42 EDT ---
(In reply to comment #2)
> No, there are no directories like that in `/static` folder. It actually refers
> to the restricted directories in the context root.

The standard DefaultServlet uses just HttpServletRequest.getPathInfo(), which
is defined to return only extra path information - that which is beyond the
mapping that selected the servlet.  So, with the "/static/*" pattern and a URL
of /context/static/WEB-INF/web.xml, the DefaultServlet went looking for
"/WEB-INF/web.xml" - and found it.

I think what would be best is to change the DefaultServlet so it includes both
getServletPath() and getPathInfo() in its result string, rather than just one
or the other.  I haven't tried it yet, but I think the following replacement
for the getRelativePath() method in DefaultServlet will work:

    protected String getRelativePath(HttpServletRequest request) {
        // Are we being processed by a RequestDispatcher.include()?
        if (request.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) != null) {
            String result =
(String)request.getAttribute(Globals.INCLUDE_PATH_INFO_ATTR);
            if (result == null) {
                result =
(String)request.getAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR);
            }
            if (result == null || result.equals("")) result = "/";
            return result;
        }
        // No, extract the desired path directly from the request.
        String result = request.getPathInfo();
        if (result == null) {
            result = request.getServletPath();
        } else {
            result = request.getServletPath() + result;
        }
        if (result == null || result.equals("")) result = "/";
        return result;
    }

You could also write your own class that extends DefaultServlet, and override
the getRelativePath() method with the above.

 - Chuck

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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