aspose file tools*
The moose likes Servlets and the fly likes HttpURLConnection seems to be doing some level of URL Decoding. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpURLConnection seems to be doing some level of URL Decoding. " Watch "HttpURLConnection seems to be doing some level of URL Decoding. " New topic
Author

HttpURLConnection seems to be doing some level of URL Decoding.

sudharsan, varadharajan
Greenhorn

Joined: Jul 12, 2001
Posts: 18
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

Joined: Feb 20, 2001
Posts: 3695

how about using java.net.URLDecoder ?
bill williams
Ranch Hand

Joined: Jan 15, 2002
Posts: 94
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).


Yet Another SCJP2
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

bill.

That doesn't meet his requirements.

forward only works within the same JVM
sendRedirect, you lose the parameters.
sudharsan, varadharajan
Greenhorn

Joined: Jul 12, 2001
Posts: 18
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpURLConnection seems to be doing some level of URL Decoding.