Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Textarea - ampersand problem

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My jsp form contains a textarea that submits to a servlet. When the textarea content includes an ampersand (&), the servlet is treating what comes after the & as a separate parameter.

How can I overcome this?

Thanks,
James
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's something you're not telling us.

Are you, for example, using Ajax? Because a "normal" form submission will handle this with no problems.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hiya Bear,

I hadn't realised, but the servlet template I had used obtained the parameters by doing...

BufferedReader paramsReader = request.getReader();
String paramsString = paramsReader.readLine();
String myParamValue = extractParamValueFromParamString("myParamName", paramsString);

The reason I'm using this technique is to overcome problems experienced with chunked encoding as the form data is very large and I have experienced problems obtaining parameter values before with such cases using the conventional request.getParameter() technique.

Temp solution to convert all "&"s in the request parameter values to "%26" works, but is there a better way??

Thanks,
James
 
Don't play dumb with me! But you can try this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic