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=13040>.
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=13040

can't retrieve external context who's uri is a sub-dir of current context





------- Additional Comments From [EMAIL PROTECTED]  2002-10-23 10:08 -------
The bit of code we're talking about is there in order to always allow for 
getting the current context, even if crossContext="false" (god knows why 
anyone would like to get the current context like that, but allowing it surely 
doesn't hurt).

I don't understand why we are adding on a trailing "/" in case the contextPath 
doesn't have one. That seems wrong to me since it would require the caller to 
say "/store/" in order to trigger the optimisation. The incoming uri we need 
to handle could be on the forms (have I missed anyone?):
"/"
"/store"
"/store/"
"/store/common"
"/store/common/even/more"

The context paths can be on the forms (again, correct me if I'm wrong):
""
"/store"

It seems we would need to treat the ROOT context differently to the rest of 
them. A propose for the fix would then be:

----------------------------------------------------------------------
--- ApplicationContext.java-2002-10-21  Mon Sep 23 11:23:16 2002
+++ ApplicationContext.java     Wed Oct 23 10:54:51 2002
@@ -439,13 +439,16 @@
             return (null);

         // Return the current context if requested
-        String contextPath = context.getPath();
-        if (!contextPath.endsWith("/"))
-            contextPath = contextPath + "/";
-        if ((contextPath.length() > 0) && (uri.startsWith(contextPath))) {
-            return (this);
-        }
-
+       if ( context.getPath().equals( "" ) ) {
+         if ( uri.equals( "/" ) ) {
+           return (this);
+         }
+       } else {
+         if ( uri.startsWith( context.getPath() ) ) {
+           return (this);
+         }
+       }
+
         // Return other contexts only if allowed
         if (!context.getCrossContext())
             return (null);
----------------------------------------------------------------------


I've tested this with the following JSP code:
<%
  ServletContext ctx = getServletContext();
  System.out.println( "/: "+ctx.getContext( "/" ) );
  System.out.println( "/publisher: "+ctx.getContext( "/publisher" ) );
  System.out.println( "/publisher/: "+ctx.getContext( "/publisher/" ) );
  System.out.println( "/publisher/protected: "+ctx.getContext
( "/publisher/protected" ) );
  System.out.println( "/publisher/protected/: "+ctx.getContext
( "/publisher/protected/" ) );
%>

With crossContext="false".

Running the JSP in the ROOT context gives me:
/: org.apache.catalina.core.ApplicationContextFacade@a45a24
/publisher: null
/publisher/: null
/publisher/protected: null
/publisher/protected/: null

Running the JSP in the /publisher context gives me:
/: null
/publisher: org.apache.catalina.core.ApplicationContextFacade@15c6c8d
/publisher/: org.apache.catalina.core.ApplicationContextFacade@15c6c8d
/publisher/protected: org.apache.catalina.core.ApplicationContextFacade@15c6c8d
/publisher/protected/: 
org.apache.catalina.core.ApplicationContextFacade@15c6c8d

Martin Algesten

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>

Reply via email to