Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 80993 invoked from network); 30 Nov 2005 17:24:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Nov 2005 17:24:35 -0000 Received: (qmail 95504 invoked by uid 500); 30 Nov 2005 17:24:32 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 94694 invoked by uid 500); 30 Nov 2005 17:24:29 -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 94683 invoked by uid 99); 30 Nov 2005 17:24:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2005 09:24:29 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.34] (HELO brmea-mail-3.sun.com) (192.18.98.34) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2005 09:25:56 -0800 Received: from phys-d3-ha21sca-2 ([129.145.155.165]) by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id jAUHO53F026833 for ; Wed, 30 Nov 2005 10:24:05 -0700 (MST) Received: from conversion-daemon.ha21sca-mail1.sfbay.sun.com by ha21sca-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IQS00K012ZOM2@ha21sca-mail1.sfbay.sun.com> (original mail from Jan.Luehe@Sun.COM) for dev@tomcat.apache.org; Wed, 30 Nov 2005 09:24:37 -0800 (PST) Received: from sun.com (sr1-umpk-13.SFBay.Sun.COM [129.146.11.187]) by ha21sca-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IQS00AT730TK1@ha21sca-mail1.sfbay.sun.com> for dev@tomcat.apache.org; Wed, 30 Nov 2005 09:24:30 -0800 (PST) Date: Wed, 30 Nov 2005 09:23:57 -0800 From: Jan Luehe Subject: Re: getContext() - spec interpretation In-reply-to: <438CBE1D.6020903@apache.org> To: Tomcat Developers List Reply-to: Jan.Luehe@Sun.COM Message-id: <438DE02D.7090807@sun.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en-US User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.4) Gecko/20041214 References: <438615BF.9020102@apache.org> <438BC26B.5010805@sun.com> <438CBE1D.6020903@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Mark, Mark Thomas wrote On 11/29/05 12:46,: > Jan, > > Jan Luehe wrote: > >>Hi Mark, > > > >>I agree the current javadocs of ServletContext.getContext() are >>ambiguous, and I agree we need to present this case to the >>Servlet EG. Maybe there is a small chance to have this resolved >>in the Servlet 2.5 timeframe ... >> >>I think it would be more useful to have the "uripath" argument be >>interpreted as a full URI rather than a context root, and have >>ServletContext.getContext() determine the longest match of the given >>"uripath" with the context roots of any deployed contexts. > > > I agree the current behaviour, which "hides" any foreign contexts > >>whose context roots match a subdir of the current context, is broken >>(in part because of the spec ambiguity), because it returns different >>results depending on the context from which the getContext() call is >>made. >> >>I don't see why we need to restrict "uripath" to be a context root in >>order to fix the current behaviour, though. As I said, returning >>the context whose context root has the longest match with the given >>"uripath" may make more sense. >> >>Would you agree? >> >> >>Jan > > > I have just re-read the spec keeping score of number of times the > wording suggests an exact match or a longest match. The result was a > draw so I am happy to interpret it either way. Given that the longest > match makes the most sense to me and won't break any existing > functionality I will take this approach until the EG issues some > clarification. Hopefully they will clarify it the "right" way. Makes sense. So it seems we could apply the patch proposed by Bill to achieve the new semantics of getContext(): MessageBytes uriMB = new MessageBytes(); uriMB.setString(uri); MappingData md = new MappingData(); MessageBytes serverName = request.getCoyoteRequest().serverName(); request.getConnector().getMapper().map(serverName, uriMB, md); if(md.context == null) { return null; } return ((Context)md.context).getServletContext(); I've rewritten the javadocs of getContext(), as follows: /** * Returns the ServletContext object to which the * specified URI has been mapped. * *

This method allows servlets to gain access to foreign servlet * contexts deployed on the same container, from which * {@link RequestDispatcher} objects may be obtained. * A servlet context is considered foreign to a servlet if it is * different from the servlet's own servlet context. * *

The given URI must be begin with "/". * *

A security conscious servlet container may return * null if the specified URI maps to a foreign context. * * @param uripath The URI to map * * @return The ServletContext to which the given URI * has been mapped, or null if the given URI does not map to any of * the servlet contexts deployed on the container, or if the URI * maps to a foreign context and access to foreign contexts has been * disabled by the container * * @see RequestDispatcher * */ public ServletContext getContext(String uripath); If we all agree, I will send this proposal to the Servlet EG. Thanks, Jan > > Mark > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org > For additional commands, e-mail: dev-help@tomcat.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org