Request object:
When browsing the web through a browser, the browser will send some requests to the server, and the server will encapsulate these requests in HttpServletRequest , and we can obtain some user's request information through this object.
Request.getparameter () is an important API to get request information , or request.getparameternames (). More usage learning, you can refer to the Servlet documentation, you can search for downloads by yourself.
In the learning process will inevitably encounter garbled problems, the solution is as follows:
The POST request method generally uses request.setcharacterencoding ("UTF-8")to set the encoding rules. If it is a GET Request method, it can be resolved in a common way, the code is as follows:
byte[] buf = username.getbytes ("iso8859-1");
Username = new String (buf, "UTF-8");
Foreigners generally use iso8859-1 encoding method, so to first to restore the code of the foreigner (server-related technology for foreigners), and then in turn UTF-8.
Request Domain:
In addition to being a Request object, request is a domain object with many request information stored in the domain.
request Domain is commonly used for forwarding, " forwarding to the feature page path "
In the case of redirection, the requesting domain for the first request cannot be used again by the requesting domain of the second request , and after redirection is a new request domain, you can also know that Request the life cycle of a domain is the start of a request to the end of a response. Obviously this request domain does not meet our daily development, we need to need a longer life cycle of servletcontext domain object, its life cycle from the Web app is deployed to stop or end.
Request study Notes