permaculture playing cards
The moose likes Java in General and the fly likes Help with (Http)URLConnection! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with (Http)URLConnection!" Watch "Help with (Http)URLConnection!" New topic

Help with (Http)URLConnection!

Saiprasad Natarajan

Joined: Oct 27, 2010
Posts: 12


I seem to have messed up the understanding of

Objective: I have 2 Webapps running on different servers. I want to transfer control from WebApp1 on Server1 to WebApp2 on Server2.
A simple response.sendRedirect(dest) would ideally suffice but since i have a pretty large amount of data to be passed on from WebApp1 to WebApp2, i do not want to send all the data in the URL hence i thought of using the HttpURLConnection.

Here is my sample Code:
From my Servlet1 in WebApp1, i do the following.

Will the above code do a redirect to WebApp2 along with the data in OutputStream?
If someone could explain what exactly URLConnection does, it would be great and if my usage of this Class in this particular context is right or not?

Thanks in Advance
Tejas Shah

Joined: Oct 26, 2009
Posts: 23

No redirection will occur ..this will send a request to webapp2.
You will be able to get response in the connection's input stream. Basically it makes your application a proxy between the target and client.

Cherish your life...!!
subject: Help with (Http)URLConnection!
It's not a secret anymore!