I answered the following question :
not getting response response = httpclient.execute(request);
See my answer there.Then I got a comment on my answer from
Peterdk
as :
The response is not a HtppResponse but a String. Or how do you get it
to be a HttpResponse? Does this depend on the ResponseHandler?
Now i have a doubt “Is HttpResponse a String ?”
Please help me clear my this doubt and explain me what was wrong in my concept.
That comment on your answer makes no sense at all to me. I also have no idea why you were down-voted, though really I don’t think the question was worded well enough to be properly answered, but if you’re really in doubt with something like this you can think through it logically by checking the docs.
Short answer:
HttpResponse is not a String.
Long answer:
The documentation for
HttpClient.execute(string)shows this as the method signature:So clearly
executereturns you anHttpResponse.Now if you go to the docs for
HttpResponseyou find thatHttpResponseis an interface and includes methods such as the method you used in your answer:getStatusLine(). Immediately you know that an interface isn’t a String, soHttpResponseisn’t aString, but in case you might think it’s the other way and maybeStringimplementsHttpResponse, it should be fairly obvious thatStringdoesn’t have a method calledgetStatusLine()and that it’d be ridiculous for something as generic as aStringto implement an interface to do with HTTP. If you really want to be sure, you can check the docs again and see thatStringdoesn’t havegetStatusLine()and doesn’t implement the interfaceHttpResponse.