// Configure Logging
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime",
"true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire",
"debug");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
"debug");
HttpClient client = new HttpClient();
String url = "http://www.discursive.com/cgi-bin/jccook/redirect.cgi";
System.out.println( "Executing Method not following redirects: ");
HttpMethod method = new GetMethod( url );
method.setFollowRedirects( false );
executeMethod(client, method);
System.out.println( "Executing Method following redirects: ");
method = new GetMethod( url );
method.setFollowRedirects( true );
executeMethod(client, method);