HttpClient in java

computeAlot picture computeAlot · May 19, 2011 · Viewed 72.1k times · Source

I want to use a simple HttpClient.

However, it appears sun.net.www.http.HttpClient is inaccessible.

Also, com.ibm.ws.http.HTTPConnection - appears to be more supporting of http server and not client. Why? Because when I create an instance of HttpConnection, it has a "getHttpResponse" to which I am supposed to write.

Anyway to use the IBM HttpConnection for HttpClient?

Or, is there any standard httpClient code that I can use?

Answer

Rob Hruska picture Rob Hruska · May 19, 2011

Many people use Apache's HTTPClient.

Have a look at the first few chapters of its tutorial to see if it's what you're looking for.

If you're after something simple that's already built into Java, you can look at HttpURLConnection, which you can use to build HTTP requests (example). If you need to do anything more than just simple HTTP requests, though, HTTPClient is probably the way to go.