Possible Duplicate:
Java – How to find the redirected url of a url?
Hi all,
Let’s say I want to know which Wikipedia page corresponds to this url:
http://en.wikipedia.org/wiki/ireland
If I navigate it with a browser, I can see that it’s http://en.wikipedia.org/wiki/Ireland.
is there a way to get the real url from a Java application?
Mulone
When you create an HttpURLConnection you can use setInstanceFollowRedirects(boolean) to prevent the connection to follow the redirect. If the response code is in the 300s, you can get the Location header which will have the redirect URL.