tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Colic" <>
Subject Re: Replacement for HTTPSessionContext!?
Date Fri, 28 Sep 2001 11:55:49 GMT

Thanks alot all.

Marco the below code was great. It was just what I needed. I have a web
application that talks to a VB backend. When the VB backend is shut down I
need all sessions invalidated. I tried implementing a session listener but
just because the VB back end goes down doesn't mean the session is
invalidated. I needed a way to iterate through the session and kill the
objects. The below code should work really well.


From: Marco Schmalz <>
Subject: Re: Replacement for HTTPSessionContext!?
Message-ID: <>

 > 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