my dog learned polymorphism
The moose likes Java in General and the fly likes HttpServlet Request getParameter automatic converting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HttpServlet Request getParameter automatic converting" Watch "HttpServlet Request getParameter automatic converting" New topic

HttpServlet Request getParameter automatic converting

Jeremy Linzer

Joined: Aug 31, 2004
Posts: 8
I am having the following issue with getParameter method of HttpServletRequest. I have a JSP which is a for musing POST method. One of the form elements is a radio button that has an ASCII value for a comma, , for its value. For example, <input type="radio" name="radioName" value="Yes, more than 60 days ago" />Yes, more than 60 days ago. When I do a request.getParameter("radioName"); on this the , is converted into an actual comma. Any ideas where exactly this is happening and why and is there anything I can do about this. This happens both on Tomcat and WSAD 5.0?

Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

Hey Jeremy-
Welcome to the JavaRanch! We've got the perflect place for servlet-y questions like this. So I'm going to move this to the Servlets forum. Please continue the conversation here.

As for your question -->
Check out the URLDecoder class. I think it will do the kind of thing you need. It's happening so that the character doesn't get corrupted.

The standard format for URL's with parameters is like this:¶m2=value2

But what if the value you were sending actually contained a "&" like "Bonnie & Clyde" That could get pretty messy, your request would look like this:

How would the application server know that the "&" inside "Bonnie+&+Clyde" was actually part of the value and not a marker to deliniate the next set of name / value pairs?? The solution is to encode all the param names and values with those funky %XX codes so no one gets confused. Make Sense?
[ September 01, 2004: Message edited by: Jessica Sant ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
I agree. Here's the link:
subject: HttpServlet Request getParameter automatic converting
It's not a secret anymore!