• 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

Problem with servlet getParameter()

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a form that is submitted using the POST method.

In my servlet I get the values using the getParameter() method. I am having a problem with "escape" characters. Whenever, I enter e.g. an expression like Exp\s*Test in a field what I receive in the servlet is Exps*Test. Basically it "cuts out" the "\" from the expression. Is there a way of getting the full entered expression?

thanks.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A google search for "java escaped characters" found this discussion and a bunch more.

It looks like you may have to do some JavaScript processing of that text field before submitting the form.

Bill
 
Sheriff
Posts: 67747
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
You posted more information on how you are constructing the form in your (now closed) cross-post (please don't do that).

It looks as if you are using out.println() in a JSP to emit HTML. Why? That's really backwards. Aside from using old-fashioned scriptlets in a JSP in the first place (explore JSTL and EL), using Java strings to build HTML is fraught with problems.

Or is that code in a Servlet? If so, why are you not using a JSP to format the HTML?

You'll need to give us more details before we can proceed. You should not need to do any special processing of the string -- the form submission will properly encode it.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use Filters for this where you can do somthing with request and response .
 
Bear Bibeault
Sheriff
Posts: 67747
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

sap patil wrote:Use Filters for this where you can do somthing with request and response .

There is no need for any filtering to get proper encoding.
 
reply
    Bookmark Topic Watch Topic
  • New Topic