Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 61130 invoked from network); 7 Aug 2008 14:16:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Aug 2008 14:16:26 -0000 Received: (qmail 5168 invoked by uid 500); 7 Aug 2008 14:16:12 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 4839 invoked by uid 500); 7 Aug 2008 14:16:12 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 4828 invoked by uid 99); 7 Aug 2008 14:16:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 07:16:12 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [76.96.62.96] (HELO QMTA09.westchester.pa.mail.comcast.net) (76.96.62.96) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 14:15:14 +0000 Received: from OMTA07.westchester.pa.mail.comcast.net ([76.96.62.59]) by QMTA09.westchester.pa.mail.comcast.net with comcast id zPDz1Z0051GhbT859SFZtz; Thu, 07 Aug 2008 14:15:33 +0000 Received: from [192.168.1.64] ([99.145.209.104]) by OMTA07.westchester.pa.mail.comcast.net with comcast id zSFC1Z00P2FhWBn3TSFJAN; Thu, 07 Aug 2008 14:15:28 +0000 X-Authority-Analysis: v=1.0 c=1 a=6oWoI7VrZPQA:10 a=rf4BGbpDofoA:10 a=xe8BsctaAAAA:8 a=plEes6nnRPTnjLG0be4A:9 a=FOMBTTC6zGnj06TVt8IA:7 a=pEyS3bZV4TmGJPe4C2NacnqV_qkA:4 a=rPt6xJ-oxjAA:10 Message-ID: <489B0372.6010309@christopherschultz.net> Date: Thu, 07 Aug 2008 10:15:14 -0400 From: Christopher Schultz User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: How to programmatically add parameters to ServletRequest objects? References: <4899DCAC.9060005@christopherschultz.net> In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jonathan, Jonathan Mast wrote: | | This is really the only way to do it. The other option is to create a | | new request object and stuff your own parameters into it (or, better | | yet, wrap the original request and add your parameters only to the | wrapper). | | How would I do this? This is basically what Jakarta Commons HTTPClient | package (org.apache.commons.httpclient.*) offers, correct? I'm pretty sure you don't want HTTPClient. What you'd do is write your own new class called something like AdditionalParameteHttpServletrsRequest and extend HttpServletRequestWrapper. Override all methods that deal with parameters and add your own parameters when appropriate. | I thought such manipulation would be achievable without additional packages. It is. You just have to write some of your own code. | | Why do you believe that adding parameters to the URL is not scalable? | Well, its not scalegent, to coin a term; | String munging is expensive (scalability), and | StringBuffer sb = new StringBuffer(); | sb.append("page.jsp?").append("foo=").append(bar).append("&color=").append(myColor).etc() | is rough to look at (elegent). String munging will be done whether you code it yourself or you delegate it to some other utility (such as the JSP's version of the same code, or to HTTPClient, or whatever). If you don't want to look at the code, put it into a utility method with an interface like MyParameterUtility.addParameter(String nanme, String value). That will also give you the opportunity to properly URI-escape both the parameter names and values. | Why not just: | HashMap myParams = new HashMap(); | myParams.put("foo", bar); | ... | pageContext.forward("page.jsp", myParams) ? Because that's not part of the interface, unfortunately. Feel free to lobby a member of the JCP to add that method to the RequestDispatcher (PageContext is a bad place to put something like that). | much more efficient and elegent, imho. No, it just hides the code you don't like to see behind an interface. You are perfectly capable of writing an interface such as that: I suggest you do it. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkibA3IACgkQ9CaO5/Lv0PAPxwCfVEbASNxwpcqDmwvFrfJu3BYF 4voAoJW5ZxuVUs88kgIghhVOL2pVLq0+ =5rcT -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org