Request. getsession. setattribute ().....

Source: Internet
Author: User

Request. getsession (). setattribute ("XXX", "XXX"); Request. setattribute (); Request. getsession (). setattribute () means to get the Session of the current session, and then setattribute to the session. The valid range is session rather than request. request. setattribute () is the setattribute to request. The valid range is that the requestsession object is a built-in JSP object and is automatically created by the container. If you use tomcat, it is created by Tomcat. If Weblogic is used, it is created by weblogic. I don't know how to create a container internally. I guess this is the case. A class that implements the httpsession interface is in the container (that is, the server) that supports servlet specifications, this class is instantiated using the singleton mode when the container is started (which may not be correct here. Then assign the instance of this class to the session. Use others' Article "Explaining the Session of the current session" means that the server cannot actively connect to the client, and can only passively wait and reply to the client request. The client connects to the server and sends an HTTP request. The server processes the request and returns an HTTP Response to the client. This HTTP request-response cycle ends. We can see that the HTTP protocol itself does not support the server to save the client status information. Therefore, the concept of session is introduced in Web server to save the state information of the client. Here we use an image metaphor to explain how the session works. Assume that the Web server is the storage space of a mall, and the HTTP request is a customer. The first time the Web Server comes to the storage space, the Administrator stores the customer's items in a cabinet (this cabinet is equivalent to a session ), then, give a number card to the customer as the packet obtaining credential (the number card is the session ID ). When the customer (HTTP request) comes to the next time, the session ID must be handed over to the administrator of the Web server. The Administrator finds the corresponding Cabinet (Session) based on the session ID. According to the customer (HTTP request) Request, the web server can retrieve, replace, and add items in the Cabinet (session, the Web server can also invalidate the Cabinet (Session) corresponding to the customer's (HTTP request) number card and number card. The customer (HTTP request) is very forgetful. When the customer (HTTP Response) returns, the Administrator must remind the customer to remember his/her session ID ). In this way, the customer (HTTP request) will come back with a number card next time. The session ID is actually transmitted between the client and the server through HTTP request and HTTP response. The session ID must be included in the HTTP request. For specific formats of HTTP requests, see http protocol (http://www.w3.org/Protocols ). Here is a brief introduction.

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.