Getting Started with httpclient

Source: Internet
Author: User
Tags pack zip

HttpClient Introduction

The HTTP protocol is probably the most frequently used and important protocol on the Internet today, and more and more Java applications need to access network resources directly through the HTTP protocol. Although the basic functionality of accessing the HTTP protocol has been provided in the JDK's java.net package, the JDK library itself offers not enough functionality and flexibility for most applications. HttpClient is a subproject under Apache Jakarta Common that provides an efficient, up-to-date, full-featured client-side Programming toolkit that supports HTTP protocols, and it supports the latest versions and recommendations of the HTTP protocol. HttpClient has been used in a number of projects, such as the other two famous Jakarta on the Apache Cactus and Htmlunit are using httpclient, and more httpclient applications can see HTTP://WI Ki.apache.org/jakarta-httpclient/httpclientpowered. The HttpClient project is very active and there are still a lot of people using it. The current HttpClient version was released in 2005.10.11 by 3.0 RC4.

HttpClient Function Introduction

The following are the main features provided by HttpClient, and more detailed features can be found in the HttpClient home page.

Implements all HTTP methods (Get,post,put,head, etc.)

Support for automatic steering

Support HTTPS Protocol

Support Proxy Server, etc.

The following describes how to use these features. First of all, we must install good httpclient.

HttpClient can be downloaded in http://jakarta.apache.org/commons/httpclient/downloads.html

HttpClient used the sub-project logging under Apache Jakarta Common, you can http://jakarta.apache.org/site/downloads/downloads_ from this address commons-logging.cgi download to common logging, remove Commons-logging.jar from the downloaded Zip pack and add to CLASSPATH

HttpClient used the sub-project codec under Apache Jakarta Common, you can http://jakarta.apache.org/site/downloads/downloads_ from this address commons-codec.cgi download to the latest common codec, remove Commons-codec-1.x.jar from the downloaded Zip pack and add it to the CLASSPATH

The use of HttpClient basic functions

Get method

The following 6 steps are required to use HttpClient:

1. Create an instance of HttpClient

2. Create an instance of a connection method, here is GetMethod. To pass in an address to be connected in the GetMethod constructor

3. Invoke the Execute method of the instance created in the first step to perform the example created in step two

4. Read response

5. Release the connection. The connection must be released, regardless of whether the execution method succeeds

6. Processing of the resulting content

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.