• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with servlet getParameter()

 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
swapnl patil
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Filters for this where you can do somthing with request and response .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!