I am using ServletRequestListener to execute certain logic when receiving requests from a web service java application.
At some point, i want to stop listening to each request received. Is there a way to stop or disable the ServletRequestListener listener programmatically?
I am using ServletRequestListener to execute certain logic when receiving requests from a web
Share
Whilst it’s possible to add a listener programmatically, it is not possible to stop or remove a listener programmatically. Best what you can do is to let it check some application wide variable before continuing and then toggle that application wide variable instead.
E.g.
and to disable it, just do
and to re-enable it, just do