I seem to have messed up the understanding of java.net.URLConnection.
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?
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.