Event listeners are similar to the filters seen in the Filters section. The difference is that event listeners start after a particular event instead of intercepting the path. The servlet specifications include a wide set of events that we will analyze in this section.
Event listeners
Session listener
The session listener works on the creation of the web session and also destroys it. Here's a simple example that logs the two events:
@WebListener
public class SampleSessionListener implements HttpSessionListener {
private static final Logger logger = getLogger(SampleSessionListener.class.getName());
@Override
public void sessionCreated(HttpSessionEvent se) {
logger.info("MySessionListener.sessionCreated: "...