Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java redirecting without sending 302

843833Mar 16 2006 — edited Mar 19 2006
If i create a URL with the address of a page that automatically redirects somewhere else the operation URL.openConnection().getcontent() returns the content of the page after redirection, but i can find no way of getting the URL of the page that the first URL redirects to. can anyone help me? Thanks in advance and if any more information is needed please ask.

example code with which to recreate the problem:
URL url = new URL("http://www.google.co.uk/search?hl=en&q=nested+Tables&btnI=I%27m+Feeling+Lucky&meta=");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

System.out.println(conn.getURL); /*prints out the first url rather than the url that the first url redirects to*/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2006
Added on Mar 16 2006
1 comment
159 views