Request study Notes

Source: Internet
Author: User

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

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.