Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
204
Chapter 9 Session Tracking
tener
, its 
valueUnbound
 method is called. With version 2.1 servlets, 
use 
removeValue
. In version 2.2, 
removeAttribute
 is preferred, but 
removeValue
 is still supported (albeit deprecated) for backward com 
patibility.
public String[] getValueNames()
public Enumeration getAttributeNames()
These methods return the names of all attributes in the session. Use 
getValueNames
 in version 2.1 of the servlet specification. In version 
2.2, 
getValueNames
 is supported but deprecated; use 
getAttribute 
Names
 instead.
public String getId()
This method returns the unique identifier generated for each session. It 
is sometimes used as the key name when only a single value is associated 
with a session, or when information about sessions is being logged. 
public boolean isNew()
This method returns 
true
 if the client (browser) has never seen the ses 
sion, usually because it was just created rather than being referenced by 
an incoming client request. It returns 
false
 for preexisting sessions. 
public long getCreationTime()
This method returns the time in milliseconds since midnight, January 1, 
1970 (GMT) at which the session was first built. To get a value useful for 
printing out, pass the value to the 
Date
 constructor or the 
setTimeIn 
Millis
 method of 
GregorianCalendar
. 
public long getLastAccessedTime()
This method returns the time in milliseconds since midnight, January 1, 
1970 (GMT) at which the session was last sent from the client. 
public int getMaxInactiveInterval()
public void setMaxInactiveInterval(int seconds)
These methods get or set the amount of time, in seconds, that a session 
should go without access before being automatically invalidated. A neg 
ative value indicates that the session should never time out. Note that 
the time out is maintained on the server and is not the same as the 
cookie expiration date, which is sent to the client.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved