Distinguish Form method = "post / get 'in (to) the form

Form and post --get embodiment provides two data transmission. Although they are a way to submit data, but in the actual transmission are very different indeed, and could have a serious impact on the data. Although for convenience to get variable values, Web container have shielded some of the differences between the two, but to understand the differences between the two in the future programming will be helpful.

Form the methods get and post, respectively in the data transmission protocol corresponds to the HTTP GET and POST methods. The two main differences are as follows:

1, Get is used to obtain data from the server, and is used to pass data to the Post on the server.

2, Get the form in accordance with the variable = value form, added to the rear of the data pointed to by URL action, and both using the connection, and using the "&" is connected between the respective variable "?"; Is a form of Post body data in form of data, and in accordance with the variable value corresponding manner, it is transmitted to the action point URL.

3, Get is unsafe, because during transmission, the data is placed in the requested URL, and now many of the existing server, proxy server or the user agent will request URL to a log file, and then placed in a place, so there may be some privacy information being viewed by third parties. In addition, users can directly see the data submitted in the browser, some of the internal system messages will be displayed together in front of the user. All operations of the Post for the user are not visible.

4. Get a small amount of data transmission, mainly because by the URL length limit; and Post can transmit large amounts of data, you can only use the Post to upload files (of course there is a reason to be mentioned in the back).

5, limit values ​​Get Form form of a data set must be ASCII characters; and Post supports the entire character set ISO10646.

6, Get is the default method Form of.

Post using transmission data, by setting the proper conversion Chinese coding method; Get the data transmission has not changed. After the program, we must pay attention to this. _________________________________________________________________________________________________

After 1, Get method to pass user data through the URL request, connecting each field name with its contents form a string in pairs, disposed within the meaning attribute url action program, such as http: //www.mdm. COM / asd the Test.asp name & password = the SAD =? , data will be displayed directly on the url, the same as if the user clicks on a link; Post method by HTTP post mechanism, each field name in the form and its content placed in the HTML header (header program transfer) together with the action attribute to the server side can be referred to a process referred to, the program (stdin) mode, the read data via a standard input form and processed 
2, Get requires the use of a variable to obtain Request.QueryString value; Post way to access the content submitted by the Request.Form 
. 3, the amount of data transmitted is very small Get embodiment, is generally limited to about 2 KB, but better efficiency than Post method; the amount of data transferred is relatively Post manner larger, it is waiting for the server to read the data, but there are byte limit, this is to prevent malicious attacks on servers with large amounts of data, based on micro Aspects of the argument, Microsoft use Request.Form () can receive the maximum data have limitations, IIS 4 for 80 KB bytes, IIS 5 for 100 KB byte 
advice: unless you are sure the data you can submit a one-time submission otherwise, please try to use the Post method 
, submit 4 Get how the data will bring security problems, such as a landing page, when submitting data through Get way, a user name and password will appear in the URL, else if the page can be cached or can access client machine, you can obtain the user ID and password from the historical record, it is recommended to submit the form using the Post method; form page Post method to submit common problem is, if you refresh the page when a dialog box will pop up
Recommendation: For security reasons, the proposal should submit data using Post

From the use of post and get the difference between the use of

First, the Form which can be used post can also use get. They are a legitimate method of value. However, post and get methods in use have at least two differences: 
. 1, the Get method of transmitting a user's input through the URL request. Post method by another form. 
2, submitted Get way you need to use Request.QueryString to get the value of a variable, while Post submission, you must access the content submitted through the Request.Form.
Prompt 
submission of data by the get method, may lead to security problems. For example, a landing page. When submitting data via the get method, user name and password will appear in the URL. If:
1, landing pages can be cached by the browser; 
2, others can access the customer's machine.
So, from someone that is in the browser history, read this customer's account number and password. So, in some cases, get method will cause serious security problems. 
Recommendation: Form recommended to use the post method.
Two, <form action = "" method = "post"> refresh prompt box will pop up when asked whether to re-send the request, if there will not be changed to method = get this prompt, the following are some of the differences and get the post

No post request length limit (at least theoretically)
GET having a length limit, a maximum of 2048 bytes (1024 characters)

Third, remember Request.QueryString () do, is get as long as you pass a value, then the string will be followed http request! You can try! The post is not in subsequent requests string http, but in the rearmost request! And invisible, the general password can be got to this pass, otherwise it can be seen directly in the address bar! ! (Although not encrypted) 
There is a post pass some more content 
then there are general use IIS filter accepts only get parameters, which is why the content of those behind the large search engines are a lot of, because the post can not be made In the past, we can only get. Look at Goole or yahoo, etc. know!

Fourth, the difference in the form submission get and post several ways summarized as follows:
1. get the data is acquired from the server, the server transmits data to a post.
2. get the parameter is added to data queue ACTION attribute of a form submission URL referred to in the various fields and values within the form-one correspondence can be seen in the URL. post through HTTP post mechanism to various fields with its contents is placed in a form HTML HEADER URL address transmitted with the ACTION attribute refers. Users do not see this process.
3. For get embodiment, a server Request.QueryString variable value acquisition for post embodiment, the server acquires data submitted by Request.Form.
4. get the amount of data transfer is small, not greater than 2KB. post large amount of data transmission, typically default to unlimited. But in theory, IIS4 the maximum amount of 80KB, IIS5 for 100KB.
5. get security is very low, post high security.

The difference between Get and Post (jsp)
the difference between Get and Post seems better than I imagined large, recently discovered at least two points using Tomcat development process:

First, when both the coding pass parameters used not necessarily the same. In Tomcat Get seem coding is based on page encoding specified, but Post is always use the same coding mode can be configured in Tomcat's server.xml.
Second, the use Get, the parameters will be displayed in the address bar, and the Post will not.
So, if these data are Chinese data and non-sensitive data, then use the get; if the user input data is not Chinese characters and contain sensitive data, or use the post as well.
When they pass a parameter encoding is not the same, get no way to encode direct delivery,
so people can see your content delivery (of course, you can take steps to avoid users to see the contents, such as Javascript dynamic organization with the URL of),
POST method is encoded transmission, and there is no special characters transfer error problem

Note: This is first copied to the interview complete free again finishing

  • http://www.cnblogs.com/hnrainll/archive/2011/06/07/2074593.html
  • http://www.cnblogs.com/hnrainll/archive/2011/06/07/2074597.html

Reproduced in: https: //www.cnblogs.com/JoannaQ/archive/2013/04/11/3013800.html

Guess you like

Origin blog.csdn.net/weixin_34306593/article/details/93056227