11.1. Obtaining Jakarta HttpClient
Problem
You need to use Jakarta HttpClient to write a program to interact with a server over HTTP.
Solution
Download Jakarta HttpClient 3.0. Following the steps outlined in
Recipe 1.1, download
“Commons HttpClient 3.0” instead of
Commons Lang. The HttpClient
archive—commons-httpclient-3.0.zip—
will
contain a file named commons-httpclient-3.0.jar
;
place this JAR file in your classpath, and you will be ready to use
Jakarta HttpClient.
Jakarta HttpClient depends on Jakarta Commons Logging, which can be obtained from the same binary download page as HttpClient. To download Commons Logging, see Recipe 7.9. Jakarta HttpClient also depends on Jakarta Commons Codec, which can also be obtained from the same binary download page as HttpClient. To download Commons Codec, see Recipe 2.15.
Discussion
Jakarta HttpClient is a client library for the HTTP protocol.
HttpClient is very feature-rich, supporting all HTTP methods defined
in RFC 2616 (Hypertext Transfer Protocol, HTTP/1.1). Jakarta
HttpClient supports GET, POST, PUT, OPTIONS, HEAD, and DELETE using
the command pattern; HttpMethod
objects are
instantiated and executed by an HttpClient
object that manages server interaction and state across multiple requests. HttpClient has support for various authentication mechanisms, including Basic, Digest, and NTLM authentication. HttpClient supports both HTTP and HTTPS, and the library can manage the complexity involved in using both schemes with an HTTP proxy. HttpClient ...
Get Jakarta Commons Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.