File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Invalidate Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Invalidate Question" Watch "Invalidate Question" New topic

Invalidate Question

Gus Mus
Ranch Hand

Joined: Feb 28, 2003
Posts: 53
Is there any way to know if the session is invalidated or not ?
Arron Zhang

Joined: Dec 27, 2002
Posts: 15
package arron;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
public class SessionCount implements HttpSessionListener {

private static int activeSessions = 0;
public static int getActiveSessions() {
return activeSessions;
public void sessionCreated(HttpSessionEvent e) {

public void sessionDestroyed(HttpSessionEvent e) {
if(activeSessions > 0) activeSessions--;

novelist & programmer
Geeta Ramasami
Ranch Hand

Joined: Mar 05, 2003
Posts: 72
For this u can implement the HttpSessionBindingListener Interface.There u have 2 methods valueBound and valueUnBound.
When a session is invalidated the valueUnBound is called inside which u can write some logic to hold the identification of the session invalidation.
I agree. Here's the link:
subject: Invalidate Question
It's not a secret anymore!