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