• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

HttpURLConnection seems to be doing some level of URL Decoding.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how about using java.net.URLDecoder ?
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic