• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection seems to be doing some level of URL Decoding.

 
sudharsan, varadharajan
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I am trying to use HttpURLConnection class
to do a POST from a servlet to an COMPLETELY
OUTSIDE URL, an URL outside of my JVM and my
Servlet Engine.
The post parameter string haS characters like
%2B, %2F, %0A, %3D to signify the ascii values
for characters +, /, '\n', = respectively.
After doing the HttpURLConnection post and
when I look at the request parameter string
in my re-directed servlet I don't see %2B, %2F, %0A etc but I see their values of +, /, '\n','=' etc. I think, the HttpURLConnection is doing some kind of URL Decoding or transformation behind the Scenes. Is there any way to solve this Problem?. Thanks,
Sudharsan.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about using java.net.URLDecoder ?
 
bill williams
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to pass the control from one page to another, you can either forward to the other page, as described above, or redirect to the new page (using the sendRedirect() method of the implicit response object).
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bill.

That doesn't meet his requirements.

forward only works within the same JVM
sendRedirect, you lose the parameters.
 
sudharsan, varadharajan
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello William and Others,
I was able to solve my problem. For some
unknown reason, HttpUrlConnection is INDEED doing
URL Decoding without being asked to do so. I tried to encode the received value in my re-directed servlet using URLEncoder and I was able
to see the ORIGINAL VALUES of the POST parameters
before the POST.
I Thank you all for the quick reply to my
problem and your valuable inputs. I really appreciate it.
Sudharsan
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic