One get URL:
Getrequesturl ()
Two get parameter list:
1.getQueryString ()
applies only to get, For example, the client sends Http://localhost/testServlet?a=b&c=d&e=f, the a=b&c=d&e=f is obtained by request.getquerystring ().
2.getParameter ()
Both get and post can be used
However, if the post request is based on the encoding of the <form> form submission data, determine whether it can be used.
Can be used when encoding is (application/x-www-form-urlencoded).
This encoding (application/x-www-form-urlencoded) is simple, but it does not seem to be enough to transmit large chunks of binary data.
For data that transmits chunks of binary numbers, the browser uses a different encoding ("Multipart/form-data"), and the following two methods are required.
3.getInputStream ()
4.getReader ()
The above two methods obtain the package body of the HTTP request packet, because the Get method request generally does not contain the package body. So the above two methods are generally used for POST request acquisition parameters.
It is important to note that:
The three methods of Request.getparameter (), Request.getinputstream (), Request.getreader () are conflicting because the stream can only be read once.
Like what:
When the form form content is enctype=application/x-www-form-urlencoded encoded, the parameters are first obtained by calling the Request.getparameter () method.
Re-calling Request.getinputstream () or Request.getreader () has no access to the contents of the stream,
Because the system may have read the data submitted in the form in the form of a stream, or vice versa, when calling Request.getparameter ().
When the form form content is enctype=multipart/form-data encoded, even if the first call to Request.getparameter () does not get the data,
So the call to the Request.getparameter () method does not conflict with Request.getinputstream () or Request.getreader ().
Even if the Request.getparameter () method has been called, the data in the form can be obtained by calling Request.getinputstream () or Request.getreader ().
Request.getinputstream () and Request.getreader () are not mixed in the same response, and if mixed use throws an exception.
"" "" "if there is anything wrong or not good enough to write, hope that the big can be put forward. Also, please leave a comment and study together. 《《《《《《《《《
How Java obtains the Get and POST request URLs and parameter lists