aspose file tools*
The moose likes Tomcat and the fly likes Can no longer put values into parameter map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Can no longer put values into parameter map" Watch "Can no longer put values into parameter map" New topic
Author

Can no longer put values into parameter map

Shishir Verma
Greenhorn

Joined: Sep 17, 2011
Posts: 2
Hi all,

I had been using TOMCAT 6.0.29 but now I have upgraded to 7.0.20. Due to compatibility issues, I had to upgrade Apache Ant as well, from 1.6.0 to 1.8.2.

Now comes the problem. Earlier request.getParameterMap.put() function used to accept java.lang.String,java.lang.String as the parameters but now it is not. I searched on the net and found that it accepts String and a String array as parameters. But since it used to work fine earlier, thus there would have been a workaround which is not present in this upgrade. Can anyone tell me how to make this work.

Thanks in advance,
Shishir(shishir4866@yahoo.com)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42293
    
  64
You should not put any values into that Map - those are the request parameters. If you need to store values with the request, use attributes.

The reason this used to work is that JEE 5 (which is what Tomcat 5 supports) did not use a typed Map - so it was a Map<Object,Object>. JEE 6 (which is what Tomcat 7 supports) returns a Map<String,String[]>, thus relieving the developer from having to cast the values.


Ping & DNS - my free Android networking tools app
Shishir Verma
Greenhorn

Joined: Sep 17, 2011
Posts: 2
"You should not put any values into that Map - those are the request parameters. If you need to store values with the request, use attributes"

Please can you post an example for it.

The command is "request.getParameterMap.put("name",diff.getName());" where getName() returns a String. I type-cast this value to a string array and the compilation passes but the API isn`t functioning properly. Please help how to resolve this issue.

Thanks,
Shishir
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

The fact that you could put values into that Map before is a bug that has been fixed. The Map implementation being used no longer allows puts into the Map.

You'll need to fix the code that relies upon this bug to do things the right way.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

In point of fact, modifying ANY part of an incoming HTTP request in Tomcat is a bad idea. It's a great way to introduce obscure bugs, security holes, and get smacked in the face when you encounter a server that plays games of its own with the request. And the server is entitled to do so, since IT owns the request, not you.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: Can no longer put values into parameter map