I wonder why does this sample code:
public class Test {
public static void main(String[] args) throws IOException {
testLink("http://google.com");
testLink("http://stackoverflow.com");
testLink("http://docs.oracle.com");
}
private static void testLink(String urlStr) throws IOException
{
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.connect();
System.out.println(conn.getResponseCode());
conn.disconnect();
}
}
Usually prints:
200
403
200
and not:
200
200
200