Reputation: 3081
I'd like to know the first time a session is created in Vaadin so I can write various data that'll be kept from request to request. Some kind of application-level listener for when a session is created/destroyed. Is this possible?
-- Shane
Upvotes: 2
Views: 611
Reputation: 2032
Yes it is possible, Create a class that implements javax.servlet.http.HttpSessionListener and annotate it with @WebListener which gives you access to method sessionCreated and sessionDestroyed.
Sample Code -
@WebListener
public class UserSessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent arg0) {
System.out.println("Session Created");
}
@Override
public void sessionDestroyed(HttpSessionEvent arg0) {
System.out.println("Session Destroyed");
}
}
That is all you have to do.
Upvotes: 3