HttpURLConnection GetFollowRedirects() Example
Returns a boolean indicating whether or not HTTP redirects (3xx) should be automatically followed.
HttpURLConnectionclass GetFollowRedirects() method example. This example shows you how to use GetFollowRedirects() method.This method Returns a boolean indicating whether or not HTTP redirects (3xx) should be automatically followed.
Here is the code:-
/*
* @Program that Returns a boolean indicating whether or not HTTP redirects
(3xx) should be automatically followed.
* GetFollowRedirects.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/
import java.io.*;
import java.net.*;
public class GetFollowRedirects {
public static void main(String[] args) throws Exception {
URL url = new URL("http://google.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Returns whether HTTP redirects should be automatically followed.
System.out.println("HTTP redirects should be automatically followed: "
+connection.getFollowRedirects());
}
} |
Output of the program:-
| HTTP redirects should be automatically followed: true |
|