hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erica Zhang <erica...@cs.ubc.ca>
Subject Why I could not get the response properly?
Date Sun, 18 Mar 2007 01:40:01 GMT
I send a POST request to the server. The response should be in text/xml 
format. However, I could not get the response properly. I also tried to 
use other methods, such as getResponseAsStream and etc. They all could 
not work. I do not know why.

The server is Tomcat + JSP + servlet. I use http client to develop the 
client .

The code is like below:

public void SendReceivePOST() {

        System.out.println("SendReceivePOST is called ");

    HttpClient client = new HttpClient();
    System.out.println("this.url is " + this.url);
    PostMethod method_tmp= new PostMethod(this.url);
    .... //this block is to add parameters to POST request ;
    try {
        System.out.println("try block begins");
              // Execute the method.
              int statusCode = client.executeMethod(method_tmp);

              if (statusCode == HttpStatus.SC_OK) {

                  this.response = method_tmp.getResponseBodyAsString() ;
                 System.out.println("this.response is" + this.response) ;

For the server, the servlet just write following string as  response:

Hunter</list><list>Richard Monson - Haefel</list><list>Kathy 
Sierra</list><list>Michael Morrison</list><list>Craig 
Larman</list><list>Hanumant Deshmukh</list></data_lists></root>

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

View raw message