GET and POST, GETPOST

Source: Internet
Author: User

GET and POST, GETPOST

The types of HTTP requests include GET, POST, PUT, DELETE, OPTIONS, TRACE, and so on. GET and POST are commonly used. The differences are as follows:

1. The GET method is used to retrieve data from the server, and the POST method is used to submit data to the server.

2. Use the GET method to submit a small amount of data to the server, which generally does not exceed 2 K. However, there is usually no limit on the amount of data submitted to the server using POST.

3. a GET request attaches the data to the URL, while a POST request places the submitted data in the Request body.

First, build a local tomcat server

1. Download To http://tomcat.apache.org and decompress to a directory (cannot be empty or Chinese)

2. Configure the environment variable: JAVA_HOME; Value: C: \ Program Files \ Java \ jdk1.8.0 _ 25

3. Run startup. bat in the bin directory of tomcat and access http: // IP: 8088.

Add a file to the ROOT directory for testing. The content is as follows:

<% String name = request. getParameter ("name"); String pwd = request. getParameter ("password"); out. print ("name:" + name + ", password:" + pwd); %>

The preceding steps use the Get method to submit data to the server. Only the request header has no request body and the data volume is limited. Instead, use the POST method to submit data to the server. The steps are as follows:

1. Construct a request object

2. Place the data to be passed to the server in the key-Value Pair object NameValuePair.

3. Store the key-Value Pair object in the List.

4. Generate a request body object

5. Place the List object in the Request body object

6. Place the Request body object in the request object

7. Send the request object and process the response data in a similar way as the get method.

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.