• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletRequest getReader() - encoding problem

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To overcome the problem of receiving request POST parameters with chunked transfer encoding, I am using the following code...

...to obtain the paramsString.

One of the parameter values being sent is an email address, but the "@" symbol is turned into "%40".

Presumably, request.getReader() is using the wrong encoding, but how do I solve it? I have tried calling request.setCharacterEncoding("UTF-8") before calling request.getReader(), but it doesn't solve.

Anyone have any ideas?
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you told post data why you are using request.getReader(). From the jsp page you can get using request.getParameter("Email String");

what is the reason behind use this..
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with using request.getParameter() is that if the request parameters are sent in chunks then you may only get the first chunk and so won't be able to access the parameters/values in subsequent chunks. That is why I use request.getReader().
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was the the request was coming from an html form.

I added this line at the end of my code snippet, and now it works fine...


Cheers,
James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic