November 2004
Intermediate to advanced
400 pages
10h 31m
English
You need to see the low-level communications between the client and the server.
Set four System variables that control logging,
and HttpClient
will
produce debugging statements dealing with environment information,
SSL configuration information, and the raw data sent to and received
from the server. The following example sets the four
System properties that control
HttpClient debugging output:
importorg.apache.commons.httpclient.HttpClient;importorg.apache.commons.httpclient.HttpException;importorg.apache.commons.httpclient.HttpMethod;importorg.apache.commons.httpclient.methods.GetMethod; String logging = "org.apache.commons.logging"; // Configure Logging System.setProperty(logging + ".Log", logging + ".impl.SimpleLog"); System.setProperty(logging + ".logging.simplelog.showdatetime", "true"); System.setProperty(logging + ".simplelog.log.httpclient.wire", "debug"); System.setProperty(logging + ".simplelog.log.org.apache.commons.httpclient", "debug"); HttpClient client =newHttpClient( ); String url = "http://www.discursive.com/jccook/"; HttpMethod method =newGetMethod( url ); client.executeMethod( method ); String response = method.getResponseBodyAsString( ); System.out.println( response ); method.releaseConnection( ); method.recycle( );
This code executes a simple GetMethod and produces
the following debugging output, which contains environment
information and a log of all data sent and received from the server:
HttpClient ...
Read now
Unlock full access