DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11652>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11652

ServletContext.getContext(anything) doesn't work from ROOT context

           Summary: ServletContext.getContext(anything) doesn't work from
                    ROOT context
           Product: Tomcat 4
           Version: 4.0.4 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


ServletContext.getContext(any uri) always returns itself, in a servlet that is
in webapp that is mapped to the / context. As a result it is impossible to
obtain the servletcontext of another webapp, from a webapp that is mapped on /.

It can be traced back to the source code:

src\catalina\src\share\org\apache\catalina\core\ApplicationContext.java

In the method getContext(String uri):

        // Return the current context if requested
        String contextPath = context.getPath();
        if (!contextPath.endsWith("/"))
            contextPath = contextPath + "/";
        if ((contextPath.length() > 0) &&
            (uri.startsWith(contextPath))) {
            return (this);
        }

Since any URI starts with /, the method will always return (this). It seems to
be an optimization, and at first sight it seems that removing this optimization
would resolve this problem.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to