I want to use a simple HttpClient.
However, it appears sun.net.www.http.HttpClient is unaccessible.
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?
Thank you.
There is another option in using google-http-java-client.
This library provides a simple and flexible API together with a pluggable approach to use low-level HTTP libraries like java.net.HttpURLConnection or Apache HTTP Client.
Sample code for posting content to content from an InputStream to a specific URL:
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.
Try jcabi-http, which acts as a wrapper of JDK
HttpURLConnection
or Apache HttpClient:Check this blog post for more information: http://www.yegor256.com/2014/04/11/jcabi-http-intro.html
I highly recommend Unirest:
You don't need a third party class, just use java's own
URL
andHttpURLConnection
classes.See an example here.
Try Apache's HTTPClient fluent API it's so easy in use!