...
HttpResponse response = httpclient.execute(httpPost);
I send a post request, then it will send back a message. How should I read the message back from the post request.
thx
...
HttpResponse response = httpclient.execute(httpPost);
I send a post request, then it will send back a message. How should I read the message back from the post request.
thx
When you say you want to read the response, that means you are reading body in the response.
Using EntityUtils
and HttpEntity
HttpEntity entity = response.getEntity();
String responseString = EntityUtils.toString(entity, "UTF-8");
System.out.println(responseString);
Using BasicResponseHandler
String responseString = new
BasicResponseHandler().handleResponse(response);
System.out.println(responseString);
Same is answered in the below post: How can I get an http response body as a string in Java?