Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 7086 invoked from network); 6 Sep 2004 19:32:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Sep 2004 19:32:17 -0000 Received: (qmail 35546 invoked by uid 500); 6 Sep 2004 19:32:06 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 35489 invoked by uid 500); 6 Sep 2004 19:32:05 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 35476 invoked by uid 99); 6 Sep 2004 19:32:05 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [195.144.64.135] (HELO smtp1.xs4all.be) (195.144.64.135) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 06 Sep 2004 12:32:04 -0700 Received: from [192.168.123.106] (195-144-088-028.dyn.adsl.xs4all.be [195.144.88.28]) (authenticated bits=0) by smtp1.xs4all.be (8.12.10/8.12.10) with ESMTP id i86JVxLg009685 for ; Mon, 6 Sep 2004 21:32:00 +0200 Message-ID: <413CBB2F.4050103@outerthought.org> Date: Mon, 06 Sep 2004 21:31:59 +0200 From: Marc Portier Organization: Outerthought User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: finding the URL of the current Cocoon application? References: <005201c4920c$2e5b3a50$970614ac@dallas.sil.org> <413C3421.20703@outerthought.org> <6.1.2.0.2.20040906091455.024e5cf0@mail.dslextreme.com> In-Reply-To: <6.1.2.0.2.20040906091455.024e5cf0@mail.dslextreme.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Ralph Goers wrote: > At 9/6/2004 02:55 AM, you wrote: > >> we've used this trick a number of times: >> >> add an action with: >> >> public Map act( Redirector redirector, SourceResolver resolver, >> Map objectModel, String source, Parameters parameters) >> throws Exception >> { >> Request request = ObjectModelHelper.getRequest(objectModel); >> >> if (request.getAttribute("mountpoint") == null) { >> String mountpoint = ""; >> String requestURI = NetUtils.decodePath(request.getRequestURI()); >> String sitemapURI = request.getSitemapURI(); >> int pos = requestURI.indexOf(sitemapURI); >> if (pos != -1) >> mountpoint = requestURI.substring(0, pos); >> request.setAttribute("mountpoint", mountpoint); >> getLogger().debug("mountpoint=" + mountpoint); >> } else >> getLogger().debug( >> "mountpoint=" + request.getAttribute("mountpoint") + " already >> set!"); >> >> return null; >> } > > > This is a good technique, but I would change > > Request request = ObjectModelHelper.getRequest(objectModel); > > to > > HttpServletRequest request = > (HttpServletRequest)objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT); > > As Lars pointed out, Cocoon's Request object can sometimes point to an > internal pipeline which is usually not what you want. > good remark, I should have noted that we only put the action in on the public pipelines (ie not internal-only) regards, -marc= -- Marc Portier http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center Read my weblog at http://blogs.cocoondev.org/mpo/ mpo@outerthought.org mpo@apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org