Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JSP Interest »

How to know if session is timeout in JSP

Edward King

2004-04-29


I make a Hashtable and put it into application,Hashtable is used to store online number,when user visited this page,I add him into this Hashtable,like follows:

Hashtable list = (Hashtable)application.getAttribute("list");
if(list==null)
list=new Hashtable();
list.put(user.getName(),user.getName());
application.setAttribute("list",list);

Then I can get online number through this Hashtable,like follows:

int number;
Hashtable list = (Hashtable) application.getAttribute("list");
Enumeration info= list.elements();
while(info.hasMoreElements())
  number++; //online number

When user's session is timeout or user closed IE,I remove user from this Hashtable.
My question is how to know user's status in Server?

Any idea will be appreciated!
Edward

===========================================================================
To unsubscribe: mailto listserv@(protected)".
For digest: mailto listserv@(protected)".

Some relevant archives, FAQs and Forums on JSPs can be found at:

http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com
©2008 junlu.com - Jax Systems, LLC, U.S.A.