In this article, we will see how to use session listeners in Java web programming.
With session listener, we can create our custom event driven code executions in web application.
HttpSessionListener is the interface that gets informed about Servlet requests.
Lets see it in an example:
@WebListener()
public class requestListener implements HttpSessionListener
{
....
Lets see it in a java example.
In above example, we created our session listener class and inherit it from HttpSessionListener . We log some message for test our session event listener work. Note that, we this time not placed our listener in web.xml, but did it with web annotation.