File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServlet Request getParameter automatic converting

 
Jeremy Linzer
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
blah.com/somepage.jsp?param1=value1¶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:

blah.com/somepage.jsp?hero=Davey+Crocket&villain=Bonnie+&+Clyde

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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic