Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can no longer put values into parameter map

 
Shishir Verma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shishir Verma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18214
53
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic