0

I have the following piece of Java code:

HttpURLConnection connection = (HttpURLConnection)new URL(url).openConnection();
connection.setRequestProperty("User-Agent","");
connection.setInstanceFollowRedirects(true);
int responseCode = connection.getResponseCode();

When the response-code is 300, how can I extract the URLs that are provided within the response body?

Thanks

barak manos
  • 29,648
  • 10
  • 62
  • 114
  • possible duplicate of [Java - How to find the redirected url of a url?](http://stackoverflow.com/questions/2659000/java-how-to-find-the-redirected-url-of-a-url) – Eric Woodruff Jan 27 '14 at 18:49
  • No duplicate. For code=300, I cannot "grab the Location header" (as the post you provide suggests), because there is no Location header in that kind of response. – barak manos Jan 27 '14 at 18:59

0 Answers0