RE: Barracuda: Bug in HttpServletRequestWrapper.getParameterMap()?
"Udovenko Sergey" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <484A6CA492BE654395D208B1D8D5393974C907@SOMEXEVS001.ex.ordersx.org> |
Hi Christian, You are right, I'm relaying on this wrapper. I need to get parameters stored/restored when the client side redirection happens. And yes, I believe I can test your fixes. Thanks. Sergey -----Original Message----- From: Christian Cryder [mailto:[email protected]] Sent: Thursday, December 05, 2002 10:15 PM To: [email protected] Subject: RE: Barracuda: Bug in HttpServletRequestWrapper.getParameterMap()? Hi Sergey, Jake, Ok, so here's the reason why we are using HttpServletRequestWrapper...it doesn't actually have anything to do with multipart requests (or at least it didn't when I created it...I think Diez has a multipart request implementation). The reason we created it is so that we can insert values into the request (which is functionality above/beyond the API). Basically, when we do a ClientSideRedirect, we need to be able to save the existing parameters so that on the subsequent request we can then re-constitute those parameters from persisted storage. Here's an example: Req 1 (POST) --> Foo.event?parm1=foo&parm2=blah FooHandler --> ClientSideRedirect Foo2.event Req 2 (GET) --> Foo2.event (Application Gateway intercedes, sees we have persisted param information, so it adjusts the request so that the handler receives the original param information) Foo2Handler --> gets Foo2.event?parm1=foo&parm2=blah So, in order to be able to "reconstitute" that URL we have to be able to shove values back into the URL. Hence, we need a wrapper which has addParameter(String name, String value). Ok, so that's the background. Given the situation, I don't see how we can NOT use our HttpServletRequestWrapper (and Diez, looking at your custom multipart wrapper, I think you might have problems following ClientSideRedirects unless you make your code extend from our wrapper...that's just a guess though; I only took a quick glance). Now, I do think we can (and should) modify it to return arrays (the problem you were trying to fix). Here's the code in question: public Map getParameterMap() { //if paramList exists, get the value from there if (paramList!=null) { Iterator it = paramList.iterator(); Map paramMap = new HashMap(paramList.size()); while (it.hasNext()) { Param param = (Param) it.next(); paramMap.put(param.getKey(), param.getValue()); } return paramMap; //otherwise just delegate to the underlying request } else { return req.getParameterMap(); } } Note that the default behavior is to just delegate the call to the underlying servlet request (which would return the data correctly). Since you are having a problem, this must mean that you are falling through the first block of code, which as I look at it, should only be happening after a client side redirection (ie. url param information got persisted, and then subsequently restored). Does that seem to jive with your situation? Assuming it does, I can go ahead and fix this. I notice another potential problem, however. Basically, the way the wrapper is currently implemented, it only allows for single parameters. In other words, if I had a URL like this: Foo.event?blah=foo1&blah=foo2&blah=foo3 after it got reconstituted it would end up like this: Foo.event?blah=foo3 So I really need to fix that too. I can go ahead and do this, but I'd like it if you can test it for me (since you obviously have code at hand to verify this with). Let me know, and then I'll procede... Christian ---------------------------------------------- Christian Cryder [[email protected]] Internet Architect, ATMReports.com Barracuda - http://barracuda.enhydra.org <http://barracuda.enhydra.org/> ---------------------------------------------- "Coffee? I could quit anytime, just not today" -----Original Message----- From: [email protected] [mailto:[email protected]]On Behalf Of Jacob Kjome Sent: Thursday, December 05, 2002 2:15 PM To: [email protected] Cc: Udovenko Sergey Subject: Re: Barracuda: Bug in HttpServletRequestWrapper.getParameterMap()? I haven't looked into the wrapper stuff so much, but now that I think about it, why the heck are we overriding methods where we aren't adding any new functionality to? As I understand it, the wrapper is only there to provide the capability to add some multipart request handling functionalty to Barracuda. Do we really need to override getParameterMap() for that....or any other method not specifically modifying behavior for a multipart request? I suppose a short-term solution would be to add Sergey's code to to fix getParameterMap() but we should think about why we are doing it in the first place and do the right thing here. Am I missing something? Jake At 12:41 PM 12/5/2002 +0100, you wrote: Seems like there is a bug in the HttpServletRequestWrapper.getParameterMap() method. According to the specification, this method suppose to return a map where values are String[] (arrays). But current implementation returning a map with just String values instead. Following quick fix worked for me: public Map getParameterMap() { Map paramMap = new HashMap(); for (Enumeration e = getParameterNames(); e.hasMoreElements();) { String name = (String)e.nextElement(); paramMap.put(name, getParameterValues(name)); } return paramMap; } regards, Sergey Udovenko This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. The sender's company reserves the right to monitor all e-mail communications through their networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of the sender's company. _______________________________________________ Barracuda mailing list [email protected] http://www.enhydra.org/mailman/listinfo.cgi/barracuda FAQ - http://www.jguru.com/faq/Barracuda