This section contains the introduction to Servlet Listener .
Introduction to Servlet Listener
Listener is one of the most popular technologies used in Java EE. Listener is predefined interface available in life cycle of application. there are two Listeners that are widely used i.e. ServletContextListener and HttpSessionListener. They both are having different functionalities but both are equally important.
In one web application, multiple listeners are allowed so it means that ServletContextListener may co-exist with HttpSessionListener .
Three Benefits of using Listeners are :
It makes the application less complex.
Saves lots of time
More maintainable
Some of the key features of ServletContextListener are given below :
If you have any requirements that need to be executed before the application is started, ServletContextListener is the best choice for you.
ServletContextListener also detects when your web application is removed.
Session Listener deals with the session object. For HTTP session events, the event listener classes can receive notification when an HTTP session is activated or is about to be deactivated, and when an HTTP session attribute is added, removed, or replaced.
[ 0 ] Comments