Filter and listener listener details
Filter and listener listener details
Filter filter
Introduction to filter
Filtering the access to resources is equivalent to the security of the community. It needs to be checked in and out.
Use of filter
Write a class that inherits and implements javax. Servlet. Filter.
Configure filter in web.xml
Filters are used to filter access, so you can use filters to do what you need to do before and after a request, such as coding settings, automatic login, etc. Series filter or something. Listen, you know what's going on.
Listener listener
Write a class inheritance to implement the following listener interface.
Listener that listens to the creation and destruction of ServletContext, httpsession and ServletRequest objects
Listeners listening for changes in ServletContext, httpsession, and ServletRequest attributes
1. Perceptual listener: no registration is required.
HttpSessionBindingListener: an instance of a class that implements the interface. It can sense when it is placed in the httpsession domain and deleted from the httpsession domain.
HttpSessionActivationListener: an instance of a class that implements the interface and can sense when it is passivated and activated with httpsession.
Configure it in web.xml
Thank you for reading, hope to help you, thank you for your support to this site!