Post and getget and post differences and usage

Source: Internet
Author: User
Tags html header
From: http://www.cnblogs.com/zhishan/articles/2441893.htmlgetand postdifferentiate and use


Many people cannot tell the difference between get and post, and when to use get? When to use post?
Both get and post Methods send data to the server, but which one should you use?
The HTTP standard includes these two methods for different purposes. Post is used to create resources. The content of resources is included in the HTTP request content. For example, processing the order form and adding new data rows to the database.
When the request has no side effects (such as search), you can use the get method. When the request has side effects (such as adding data rows to the database), you can use the POST method. A more practical problem is that the get method may produce a long URL, which may exceed the URL length limit of Some browsers and servers.
If any of the following conditions is met, the POST method is used:



The request results have continuous side effects, such as adding new data rows to the database.
If the get method is used, the data collected on the form may make the URL too long.
The data to be transmitted is not encoded in 7-bit ASCII format.



If any of the following conditions is met, use the get method:



The request is for searching resources. HTML form data is only used for searching.
The request results have no sustained side effects.
The total length of the  and input field names in the HTML form cannot exceed 1024 characters.



Difference between get and post methods in Form submission
1. Get is to get data from the server, and post is to send data to the server.



2.
Get adds the parameter data queue to the URL referred to by the Action attribute of the submission form. The values correspond to each field in the form one by one and can be seen in the URL. Post is implemented through HTTP
Post mechanism: place the fields in the form and their content in the HTML header and send them to the URL address referred to by the Action attribute. You cannot see this process.



3. For the get method, the server uses request. querystring to obtain the value of the variable. For the POST method, the server uses request. Form to obtain the submitted data.



4. The data volume transmitted by get is small and cannot exceed 2 kb. The amount of data transmitted by post is large, which is generally not restricted by default. Theoretically, the maximum size of IIS4 is 80 KB, and that of iis5 is 100kb.



5. Low get security and high post security.



 



Get and post methods in HTML form Form



in the B/S application ,
Data Interaction Between the foreground and the background, all are completed through form in HTML. Form provides two data transmission methods ?? Get and post. Although they are all data submission methods,
they are indeed quite different in actual transmission and may have a serious impact on data. Although the Web Container has shielded some differences between the two to get variable values conveniently, it will be helpful to understand the differences between the two in later programming.
.
The get and post methods in form correspond to the get and post methods in the HTTP protocol during data transmission. The main differences are as follows:
1. Get is used to  from the server, while post is used to transmit data to the server.
2.
Get adds the data in the form of variable = value to the URL pointed to by action, and the two use "?" And each variable is connected by "&
AMP;". Post stores the data in the form data body, which corresponds to the variables and values, the URL indicated by the action.
3. Get is insecure because data is stored in the request URL during transmission, however, many existing proxy servers or user agents record the request URL to the log file, and put it somewhere, so that some private information may be seen by a third party. In addition, you can view the submitted data in the browser , some internal messages are displayed in front of users. All post operations are invisible to users.
4. Get transfers a small amount of data, mainly because it is restricted by the URL length, while post can transmit a large amount of data, therefore, you can only use post when uploading files in (of course, there is another reason, which will be mentioned later ).
5. Get restricts that the dataset value of form forms must be ASCII characters, while post supports the entire iso000046 character set.
6. Get is the default form method.



The following is a brief introduction of contenttype, which corresponds to the enctype attribute in form. It is a form used to organize data, mainly including two types:
1,
Application/X-WWW-form-urlencoded: it is the default content type (Content
Type). In the result, we can see the effect of the data encoded by it. Encoding method: I. Replace the space with "+". It is a non-letter or numeric character expressed in % HH.
ASCII replacement (Chinese characters in this form); II. Use "=" for variables and values, and use "&" for connections between variables and value pairs.
2,
Multipart/form-data: it can be used to transmit a large amount of binary data or non-ASCII text. Therefore, you must set
Enctype = "multipart/form-Data", the method must be post. The message it transmits contains a series of data blocks, each representing
A variable in form, and the data block sequence is the same as the order on the page, the block and the block are separated by special characters (Boundary. If the form contains the file control
The data block also contains a Content-Type header to specify mime. The default value is text/plain. Set enctype = "multipart
/Form-data:



Many people cannot tell the difference between get and post, and when to use get? When to use post?
Both get and post Methods send data to the server, but which one should you use?
The HTTP standard includes these two methods for different purposes. Post is used to create resources. The content of resources is included in the HTTP request content. For example, processing the order form and adding new data rows to the database.
When the request has no side effects (such as search), you can use the get method. When the request has side effects (such as adding data rows to the database), you can use the POST method. A more practical problem is that the get method may produce a long URL, which may exceed the URL length limit of Some browsers and servers.
If any of the following conditions is met, the POST method is used:



The request results have continuous side effects, such as adding new data rows to the database.
If the get method is used, the data collected on the form may make the URL too long.
The data to be transmitted is not encoded in 7-bit ASCII format.



If any of the following conditions is met, use the get method:



The request is for searching resources. HTML form data is only used for searching.
The request results have no sustained side effects.



Difference between get and post methods in Form submission
1. Get is to get data from the server, and post is to send data to the server.



2.
Get adds the parameter data queue to the URL referred to by the Action attribute of the submission form. The values correspond to each field in the form one by one and can be seen in the URL. Post is implemented through HTTP
Post mechanism: place the fields in the form and their content in the HTML header and send them to the URL address referred to by the Action attribute. You cannot see this process.



3. For the get method, the server uses request. querystring to obtain the value of the variable. For the POST method, the server uses request. Form to obtain the submitted data.



4. The data volume transmitted by get is small and cannot exceed 2 kb. The amount of data transmitted by post is large, which is generally not restricted by default. Theoretically, the maximum size of IIS4 is 80 KB, and that of iis5 is 100kb.



5. Low get security and high post security.



 



Get and post methods in HTML form Form



in the B/S application ,
Data Interaction Between the foreground and the background, all are completed through form in HTML. Form provides two data transmission methods ?? Get and post. Although they are all data submission methods,
they are indeed quite different in actual transmission and may have a serious impact on data. Although the Web Container has shielded some differences between the two to get variable values conveniently, it will be helpful to understand the differences between the two in later programming.
.
The get and post methods in form correspond to the get and post methods in the HTTP protocol during data transmission. The main differences are as follows:
1. Get is used to  from the server, while post is used to transmit data to the server.
2.
Get adds the data in the form of variable = value to the URL pointed to by action, and the two use "?" And each variable is connected by "&
AMP;". Post stores the data in the form data body, which corresponds to the variables and values, the URL indicated by the action.
3. Get is insecure because data is stored in the request URL during transmission, however, many existing proxy servers or user agents record the request URL to the log file, and put it somewhere, so that some private information may be seen by a third party. In addition, you can view the submitted data in the browser , some internal messages are displayed in front of users. All post operations are invisible to users.
4. Get transfers a small amount of data, mainly because it is restricted by the URL length, while post can transmit a large amount of data, therefore, you can only use post when uploading files in (of course, there is another reason, which will be mentioned later ).
5. Get restricts that the dataset value of form forms must be ASCII characters, while post supports the entire iso000046 character set.
6. Get is the default form method.



The following is a brief introduction to contenttype, which corresponds to the enctype attribute in form. form is used to organize data. It mainly includes two types:
1.
application/X-WWW-form-urlencoded: it is the default content type (content
type ), in the result, we can see the effect of the data encoded by it. Encoding method: I. replace spaces with "+", which is not a letter or number character. It is replaced by
ASCII (in this form of Chinese characters) expressed in % HH. II. use "=" for variables and values, and use "&" for connections between variables and value pairs.
2.
multipart/form-data: it can be used to transmit large amounts of binary data or non-ASCII text, therefore, you must set
enctype = "multipart/form-Data" When uploading files. The method must be post. The message it transmits contains a series of data blocks, each representing a variable in
form, and the data block sequence is consistent with the order on the page, blocks are separated by special characters (Boundary. If the form contains the file control, the
data block also contains a Content-Type header to specify mime. The default value is text/plain. The following is the content result when enctype = "multipart
/form-Data" is set:


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.