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:
- ServletRequestEvent
- ServletContextEvent
- ServletRequestAttributeEvent
- ServletContextAttributeEvent
- HttpSessionEvent
- HttpSessionBindingEvent
Event interfaces
The event interfaces are as follows:
- ServletRequestListener
- ServletRequestAttributeListener
- ServletContextListener
- ServletContextAttributeListener
- HttpSessionListener
- HttpSessionAttributeListener
- HttpSessionBindingListener
- HttpSessionActivationListener
Upcoming topics in Servlet Events and Listeners
ServletContextEventLet’s see the simple example of ServletContextEvent and ServletContextListener
HttpSessionEventLet’s see the simple example of HttpSessionEvent and HttpSessionListener
ServletRequestEventLet’s see the simple example of ServletRequestEvent and ServletRequestListener
ServletContext AttributeEventLet’s see the simple example of ServletContextAttributeEvent and ServletContextAttributeListener
HttpSessionBindingEventLet’s see the simple example of HttpSessionBindingEvent and HttpSessionAttributeListener
ServletRequestAttributeEventLet’s see the simple example of ServletRequestAttributeEvent and ServletRequestAttributeEvent
Leave A Comment