How to get redirected URL and content using HttpURLConnection
问题 Sometimes my URL will redirect to a new page, so I want to get the URL of the new page. Here is my code: URL url = new URL("http://stackoverflow.com/questions/88326/"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setInstanceFollowRedirects(true); System.out.println(conn.getURL().toString()); The output is: stackoverflow.com/questions/88326/does-elmah-handle-caught-exceptions-as-well It works well for the Stack Overflow website, but for the sears.com site, it doesn