Events are basically occurrence of something. Changing the state of an object is known as an event.

We can perform some important tasks at the occurrence of these exceptions, such as counting total and current logged-in users, creating tables of the database at time of deploying the project, creating database connection object etc.

There are many Event classes and Listener interfaces in the javax.servlet and javax.servlet.http packages.

Event classes

The event classes are as follows:

  1. ServletRequestEvent
  2. ServletContextEvent
  3. ServletRequestAttributeEvent
  4. ServletContextAttributeEvent
  5. HttpSessionEvent
  6. HttpSessionBindingEvent

Event interfaces

The event interfaces are as follows:

  1. ServletRequestListener
  2. ServletRequestAttributeListener
  3. ServletContextListener
  4. ServletContextAttributeListener
  5. HttpSessionListener
  6. HttpSessionAttributeListener
  7. HttpSessionBindingListener
  8. HttpSessionActivationListener