• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getParameter with double quotes

 
Jeff Hancock
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a servlet that is using the request objects getParameter() method to retrieve a string. The string contains a double quote (") and is therefore truncated somewhere between the client and the servlet. Is there anyway to retrieve the value in it's entirety without truncating? the value is (3/16"):ABSBT. Am only getting (3/16
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This needs to be handled when the parameter is being posted, not when being retrieved. If the request parameter is posted as part of a form, all would be well. So I suspect that somewhere along the line the parameter is being tacked onto a URL "by hand".
When doing so, it is very important to make sure that the parameter value is url-encoded using java.net.URLEncoder.
hth,
bear
 
Jeff Hancock
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the quick response. Actually, the field is part of an HTML textbox. The getparameter just gets the value from the text box. If the user types in a double quote, it is too late to encode it isn't it.

It isn't being passed in as part of the query string. The method is post.
Thank you again.
 
DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to build an escape object or replacement object in Javascript so the data is sent across the internet correctly. At the least you should alert the usert that an illegal character has been found in the textbox & then simply remove it for them. A " is a terminator for data when being transfered so,yes , you will loose anything after that
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the value is being posted via a form it is certainly being sent across correctly unless there's a serious bug in your web server. A quote character is most certainly not an illegal character and a user is free to enter it into a text field.
Are you sure that the call to getParameter() is returning the truncated value, or is it being lost upon display? For example, if your HTML is ending up like the following:

the browser will not render the field with the full value.
if that's the case, you should encode the string upon display.
hth,
bear
[ January 10, 2003: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic