Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 29706 invoked from network); 4 Dec 2005 18:35:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Dec 2005 18:35:04 -0000 Received: (qmail 85623 invoked by uid 500); 4 Dec 2005 18:35:03 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 84554 invoked by uid 500); 4 Dec 2005 18:34:59 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 84543 invoked by uid 500); 4 Dec 2005 18:34:59 -0000 Delivered-To: apmail-jakarta-tomcat-dev@jakarta.apache.org Received: (qmail 84534 invoked by uid 99); 4 Dec 2005 18:34:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Dec 2005 10:34:59 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 04 Dec 2005 10:34:58 -0800 Received: (qmail 29572 invoked by uid 65534); 4 Dec 2005 18:34:38 -0000 Message-ID: <20051204183438.29571.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r353884 - /tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java Date: Sun, 04 Dec 2005 18:34:38 -0000 To: tomcat-dev@jakarta.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: markt Date: Sun Dec 4 10:34:35 2005 New Revision: 353884 URL: http://svn.apache.org/viewcvs?rev=353884&view=rev Log: Fix bug 13040. getContext() now allows retrieval of an external context that is a sub-context of the current context. Modified: tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java Modified: tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java URL: http://svn.apache.org/viewcvs/tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java?rev=353884&r1=353883&r2=353884&view=diff ============================================================================== --- tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java (original) +++ tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java Sun Dec 4 10:34:35 2005 @@ -404,8 +404,8 @@ * obtain RequestDispatcher objects or resources from the * context. The given path must be absolute (beginning with a "/"), * and is interpreted based on our virtual host's document root. - * - * @param uri Absolute URI of a resource on the server + * @param uri a String specifying the context path of a web + * application in the container. */ public ServletContext getContext(String uri) { @@ -413,26 +413,24 @@ if ((uri == null) || (!uri.startsWith("/"))) return (null); - // Return the current context if requested - String contextPath = context.getPath(); - if (!contextPath.endsWith("/")) - contextPath = contextPath + "/"; - - if (((contextPath.length() > 1) && (uri.startsWith(contextPath))) || - ((contextPath.equals("/")) && (uri.equals("/")))) { - return (this); - } - - // Return other contexts only if allowed - if (!context.getCrossContext()) - return (null); + // Use the host mapper to match the uri to a context try { Host host = (Host) context.getParent(); Context child = host.map(uri); - if (child != null) - return (child.getServletContext()); - else - return (null); + if (child != null) { + // Without crossContext, can only return the current context + if (context.getCrossContext()) { + return child.getServletContext(); + } else { + if (context == child) { + return (this); + } else { + return (null); + } + } + } else { + return (null); + } } catch (Throwable t) { return (null); } @@ -1105,28 +1103,6 @@ } } parameters = results; - - } - - - /** - * List resource paths (recursively), and store all of them in the given - * Set. - */ - private static void listPaths(Set set, DirContext resources, String path) - throws NamingException { - - Enumeration childPaths = resources.listBindings(path); - while (childPaths.hasMoreElements()) { - Binding binding = (Binding) childPaths.nextElement(); - String name = binding.getName(); - String childPath = path + "/" + name; - set.add(childPath); - Object object = binding.getObject(); - if (object instanceof DirContext) { - listPaths(set, resources, childPath); - } - } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org