About session control

xiaoxiao2021-03-06  51

??????? These days do the weather forecast for Oracle IAS10G, because of the use of servlets (possibly the level of my own level), in the data of the session data, in fact, it is often used, but before There is a problem, and it is sometimes none of this time, it may be related to portlet. Soxing records the information and adjournment:

??????? session is a flexible, lightweight mechanism that makes status on the page possible. HTTP is a stateless protocol. When the user issues a request, the server responds, the client responds, and the connection between the client and the server is discrete, discrete. When the user is converted between the multipage of the same website, it is impossible to know if the same customer will solve this problem. When a customer switches between multiple pages, the server saves the user's information.

?????? On the server, the user's information is saved by creating a session object on the site. When the user first accesses the site, assign a session object and a single alive ID, and the id is only one. In the next request, the session ID identifies the user, and the object is sent as part of the request to the servlet, and the servlet can read information from the session object, or add information.

?? Cookie is a small piece of data that can embed HTTP requests and responses. It is generated on the server and is returned to the customer as part of the response header. After receiving a Cookie response, the browser is written to a text file that stores a cookie in the form of "Keyword / Value". The browser will send the cookie's information to the request to the server so that the server can read data again. Cookies can set the validity period, and the browser does not send expired cookies to the server.

??????? JSP uses an object called HTTPSession to achieve the same function. The SESSION information is saved in the server side, and the session ID is saved in the cookie of the client. If the client prohibits cookies, the session ID must be taken behind the URL. Session typically sets a 30-minute expiration time on the server and automatically invalidate after the customer stops the activity. The information saved and retrieved in the session cannot be the basic data type (int, double), etc., but must be the corresponding Object (object) of Java (INTEGER, DOUBLE). HttpSessionSession = Request.getSession (); // Get a session object or create a session.getid () // get the sessionID number integer = (Integer) // Retrieve the value of the session and converted to Integer session.putValue ("itemValue, itemname); // ItemValue must not be a Must simple type

???????? I used it when I tested:

转载请注明原文地址:https://www.9cbs.com/read-117500.html

New Post(0)