tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Schmalz <>
Subject Re: Replacement for HTTPSessionContext!?
Date Fri, 28 Sep 2001 10:19:46 GMT
 > I am looking for a way to get a list of sessions and then invalidate 

use a Set with all sessions in it and store it in the ServletContext.

btw, im more likely to write code than to explain it with words. voilĂ :

//create a set to store the sessions and put it into the ServletContext
Set sessions = Collections.synchronizedSet(new HashSet());
getServletContext().setAttribute("myproj.sessions", sessions);

//when a user logs in:
Set sessions = (Set)getServletContext().getAttribute("myproj.sessions");

//when you want to invalidate all sessions:
Iterator sessionIt = 
while(sessionIt.hasNext()) {
	HttpSession session = (HttpSession);

i hope this helps

View raw message