This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with (Http)URLConnection!" Watch "Help with (Http)URLConnection!" New topic
Author

Help with (Http)URLConnection!

Saiprasad Natarajan
Greenhorn

Joined: Oct 27, 2010
Posts: 12

Hi

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?

Thanks in Advance
Sai
Tejas Shah
Greenhorn

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.

-Tejas
Cherish your life...!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with (Http)URLConnection!
 
Similar Threads
Passing parameters to url using java.net package
Simple Question - AJAX and JAVA, Is It Possible?
Java Website post
post request to url
HTTPS Post Request through the URL