I'm developing in java an application which verifies if one site is online. I get the http response by:
URL url = new URL("http://www.example.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
But when I access the URL it is redirecting and the HTTP response is always 301. I want to get the new URL that the site was redirected. Is it possible?