Apache Struts 2 Documentation > Home > FAQs > How do we get invalidate the session
Added by Dave Newton, last edited by Dave Newton on Jul 01, 2007  (view change) show comment

See How do we get access to the session for ways to retrieve the session.

One way of invalidating a session; contributed by Ray Clough.

Session Invalidation
// Code fragment from class implementing SessionAware containing the 
// session map in a instance variable "session". Attempting to invalidate 
// an already-invalid session will result in an IllegalStateException.
if (session instanceof org.apache.struts2.dispatcher.SessionMap) {
    try {
        ((org.apache.struts2.dispatcher.SessionMap) session).invalidate();
    } catch (IllegalStateException e) {
        logger.error(msg, e);
    }
}