Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 96882 invoked from network); 2 Mar 2004 00:24:25 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Mar 2004 00:24:25 -0000 Received: (qmail 68120 invoked by uid 500); 2 Mar 2004 00:23:46 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 68063 invoked by uid 500); 2 Mar 2004 00:23:46 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 68022 invoked from network); 2 Mar 2004 00:23:46 -0000 Received: from unknown (HELO brmea-mail-3.sun.com) (192.18.98.34) by daedalus.apache.org with SMTP; 2 Mar 2004 00:23:46 -0000 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 i220Nri5022535 for ; Mon, 1 Mar 2004 17:23:53 -0700 (MST) Received: from sun.com (raga2.SFBay.Sun.COM [129.145.132.30]) by ha21sca-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with ESMTP id <0HTX0090LAFSJ7@ha21sca-mail1.sfbay.sun.com> for tomcat-dev@jakarta.apache.org; Mon, 01 Mar 2004 16:23:52 -0800 (PST) Date: Mon, 01 Mar 2004 16:23:52 -0800 From: Jan Luehe Subject: Re: Question about HttpServletRequest.getParameterValues() In-reply-to: To: Tomcat Developers List Reply-to: Jan.Luehe@Sun.COM Message-id: <4043D418.80500@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; 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.2.1) Gecko/20030711 References: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Christian, > The 2.3 HttpServletRequest interface provides a setAttribute() method to > change the values of a given attribute. It does NOT however provide a > similar setParameter() method, allowing you to programatically modify the > values that accompany the request - I assume this means that we shouldn't be > able to change these values. > > What I've discovered however, is that if I _can_ modify parameter values by > calling getParameterValues() (which returns String[]) and set the values > that way. For instance: > > Enumeration enum = req.getParameterNames(); > while (enum.hasMoreElements()) { > String key =(String) enum.nextElement(); > String vals[] = req.getParameterValues(key); > for (int i=0, max=vals.length; i if (key.equalsIgnoreCase("password")) vals[i] = "********"; > logger.info("...key:"+key+" value:"+vals[i]); > } > } > > This has the surprising (to me anyway) effect of actually _modifying_ the > underlying value for the particular key. Is this simply an implementation > oversight? I had assumed that the method would be returning a copy of the > underlying data structure, rather than a reference to the structure itself. > > This isn't really a problem for me, but I thought it was interesting and I'm > curious to know if this was intentional or not. Anyone care to comment? This is a bug. The String[] returned by req.getParameterValues() should have been a clone. I just committed a fix. Thanks, Jan > Thanks much, > Christian > ---------------------------------------------- > Christian Cryder > Internet Architect, ATMReports.com > Project Chair, BarracudaMVC - http://barracudamvc.org > ---------------------------------------------- > "Coffee? I could quit anytime, just not today" > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org