JSP Session Usage
<% @page contenttype= "text/html;charset=gb2312"%>
Session object: An object that is used to hold each user's information separately to facilitate tracking of the user's operational status. The session's information is saved on the service side, and the session ID is stored in the client's cookie. In fact, on many servers, cookies are used directly if the browser supports cookies. But if you do not support or abolish cookies, automatically converted to url-rewriting, session automatically provides a convenient way to store information for each process. The corresponding session objects for different users are generally different. For example, when a user logs on to a site, the system creates a session object that is not the same as the other and makes it easy to distinguish other users. This session object records the user's personal information and disappears when the user exits the site.
About Session.isnew (); Generally returns true because a session is automatically created on first access in the JSP. The code that executes automatically is as follows:
HttpSession session=request.getsession ();
Main methods:
1.getAttribute (String name)
Gets the information that is associated with the specified name.
2.getAttributeNames ()
Returns each Property object stored in the session object, with the result being a class-lifted instance
3.getCreationTime ()
Returns the time the session was created. The minimum unit is 1 per thousand seconds.
4.getId ()
This method returns a unique identity, which is generated for each session. When there is only one single value associated with a session, or when the log information is related to a previous session, it is used as a key name.
5.GetLastAccessedTime ()
Returns the time at which the current session object was last sent by the customer, at a maximum of 1 per thousand seconds.
6.GetMaxInactiveInterval ()
Returns the total time (in seconds), and a negative value indicates that the session never times out. The time is the lifetime of the session object.
7.removeAttribute (String name)
Deletes the information associated with the named name.
8.setAttribute (String name, java.lang.Object value)
Sets the attribute value value of the specified name, and stores it in the session object.