J2EE listeners mini tutorial

You can listen to servlet container  and http session events using

  • javax.servlet.ServletContextListener
  • javax.servlet.http.HttpSessionListener

ServletContextListener :
This interface contains two methods :

  • public void contextInitialized(ServletContextEvent sce);
  • public void contextDestroyed(ServletContextEvent sce);

The HttpSessionListener interface also contains just two methods, for session creation and invalidation events respectively :

  • public void sessionCreated(HttpSessionEvent se);
  • public void sessionDestroyed(HttpSessionEvent se);

There are also these:



(These are only available from a particular j2ee version. So check the j2ee version before using them)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: