Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 51613 invoked from network); 29 Jan 2007 18:54:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Jan 2007 18:54:47 -0000 Received: (qmail 44715 invoked by uid 500); 29 Jan 2007 18:54:51 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 44651 invoked by uid 500); 29 Jan 2007 18:54:51 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 44639 invoked by uid 99); 29 Jan 2007 18:54:51 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2007 10:54:51 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [130.237.222.115] (HELO smtp.nada.kth.se) (130.237.222.115) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2007 10:54:41 -0800 X-Authentication-Info: The sender was authenticated as danielf using PLAIN at smtp.nada.kth.se Received: from [192.168.105.137] ([62.84.203.102]) (authenticated bits=0) by smtp.nada.kth.se (8.12.11.20060308/8.12.11) with ESMTP id l0TIsJCn009875 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 29 Jan 2007 19:54:19 +0100 (MET) Message-ID: <45BE42D5.60002@nada.kth.se> Date: Mon, 29 Jan 2007 19:54:13 +0100 From: Daniel Fagerstrom User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: dev@cocoon.apache.org Subject: Re: ${cocoon.request.contextPath} returns null in 2.2 References: <45BBBCF0.1000002@tuffmail.com> <45BCFD51.3080205@nada.kth.se> <45BDBC85.4090205@nada.kth.se> <45BDD5C7.4090100@tuffmail.com> In-Reply-To: <45BDD5C7.4090100@tuffmail.com> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Grzegorz Kossakowski skrev: > Daniel Fagerstrom napisa�(a): > >> Daniel Fagerstrom skrev: >> >>> Grzegorz Kossakowski wrote: >>> >>>> Hello, >>>> >>>> I'm hacking now ajax and forms block to get them use of >>>> servlet-services >>>> and came across a bug. When you put ${cocoon.request.contextPath} into >>>> JX template it will always return null (at least while using servlet >>>> dispatcher). However, ${cocoon.request.requestURI} returns valid value, >>>> so it must be only contextPath broken somehow. Unfortunately, I have no >>>> skills to debug this. >>>> Anyone can at least confirm this? Can you test it without servlet >>>> dispatcher? (I would do it myself if I knew how) >>>> >>>> >>> I have not tested it. But looking at the code the servlet dispatcher >>> just embeds the request object from the servlet container with a >>> proxy. And the proxy doesn't affect the contextPath AFAICS, so it >>> might be that the context path is null in the original request. >>> >>> For a servlet service that is called through the servlet protocol, >>> the contextPath will always be "", which is a bug. Currently the >>> request object of the calling servlet service is not available in the >>> servlet source, so there is no easy fix. I plan to refactor the call >>> stack and make it available there. >>> >>> In the servlet architecture we have: >>> >>> requestURI = contextPath + servletPath + pathInfo >>> >>> As the servlet service architecture creates an extra level of paths >>> relative to the servlet architecture there are several possibilities >>> where to add the mountPath. I solved it in the following way: the >>> dispatcher servlet will look for the mountPath that is the longest >>> prefix in the incoming pathInfo. It will then create a new >>> servletPath and pathInfo for the called servlet service: >>> >>> newServletPath = servletPath + mountPath >>> newPathInfo = pathInfo.substring(mountPath.length()) >>> >>> So as you can see the contextPath will be the same as for all servlet >>> services. >>> >> Taking a look at your patches in JIRA I see that you have replaced >> {request:contextPath}/_cocoon/resources >> with >> /blocks-test/cocoon-forms-impl/resources >> >> Now the original pattern is actually faulty (even if it seem to be >> used everywhere in the samples), it should have been >> {request:contextPath}{request:servletPath}/_cocoon/resources >> and >> {request:contextPath}{request:servletPath}/resources >> in your refactored code. >> >> The only reason that the samples work is that the web.xml in >> cocoon-webapp mounts the sitemap servlet at "/*" which gives >> servletPath="", but there is no reason to constrain the use of the >> sitemap servlet to be used only with an empty servlet path. A servlet >> is supposed to be mountable wherever the user want it. >> >> Using the servlet service fw, sitemap servlets will be mounted at >> other paths and the servletPath must be taken into account. >> > Thanks for explanation. However, your proposed solution will not work. > In cocoon-ajax-sample we have: >