Filters are like servlets but managed by the web container but there is service() method in servlets but there is no method called service in filters. There are three only three methods init(), doFilter(), and destroy().Can anybody elaborate on this ?
Filters are like servlets but managed by the web container but there is service()
Share
The doFilter() method is the one that is called whenever a Filter processes a request.
A simple example is as follows:
The filter allows you to decide whether to continue processing the request i.e. whether subsequent filters will process this request and finally the servlet at the end. You can choose not to call chain.doFilter (good example of this would be if you’re using the filter for authentication). See this guide for more information.