Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Listener for Session Expiration

Bill Burdick
1 decade ago Apr 05, 2010 9:00pm
Joonas Lehtinen
1 decade ago Apr 06, 2010 5:54am

Override Application.close() - it will get called when the application end (either explicitly or by session expiration).

Artur Signell
1 decade ago Apr 06, 2010 5:56am
Bill Burdick
1 decade ago Apr 06, 2010 12:49pm
David Wall
1 decade ago Apr 06, 2010 3:48pm
Joonas Lehtinen
1 decade ago Apr 06, 2010 3:53pm
Gugan Mohan
8 years ago Oct 16, 2013 7:11am
michakl asdasdasd
8 years ago Oct 16, 2013 10:41am
import com.vaadin.server.VaadinSession;
import java.util.Enumeration;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebListener
public class SessionExpireListener implements HttpSessionListener {
    
    @Override
    public void sessionCreated(HttpSessionEvent hse) {
        System.out.println("Session created");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent hse) {
        System.out.println("Session destroyed");
        Enumeration e = hse.getSession().getAttributeNames();
        while (e.hasMoreElements()) {
            Object o = hse.getSession().getAttribute((String) e.nextElement());
            if (o instanceof VaadinSession) {
                VaadinSession vs = (VaadinSession) o;
            }
        }        
    }
}
anto praveen fathima xavier
7 years ago May 19, 2014 2:52pm

where should we add this SessionExpireListener?

Arun Prakash
6 years ago Aug 12, 2015 2:03pm
Martin Vyšný
3 years ago Sep 27, 2018 6:40am