Just use
org.apache.commons.httpclient.methods.PostMethod.getRequestBodyAsString()
and
org.apache.commons.httpclient.methods.PostMethod.getResponseBodyAsString()
or the equivalent method of
org.apache.commons.httpclient.methods.GetMethod

To check how to use them from
http://jakarta.apache.org/commons/httpclient/tutorial.html

    // Create an instance of HttpClient.
    HttpClient client = new HttpClient();

    // Create a method instance.
    GetMethod method = new GetMethod(url);

    // Provide custom retry handler is necessary
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                new DefaultHttpMethodRetryHandler(3, false));

    try {
      // Execute the method.
      int statusCode = client.executeMethod(method);

      if (statusCode != HttpStatus.SC_OK) {
        System.err.println("Method failed: " + method.getStatusLine());
      }

      // Read the response body.
      byte[] responseBody = method.getResponseBody();




On 12/20/05, Xiaobo Yang <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I managed to output the http request head by adding a println statement in
> HttpConnection.java (write method). When I tried to output the http request
> body, I found it to be a OutputStream object. Could anybody tell me how to
> print out the http request body? Also I wonder how to output the http
> response for debugging purpose. Thanks in advanced.
>
> Regards,
> Xiaobo Yang
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to