doFilter method. Every Filter has access to a FilterConfig object from
which it can obtain its initialization parameters, a reference to the ServletContext which it can use, for example,
to load resources needed for filtering tasks.
Filters are configured in the deployment descriptor of a web application
Examples that have been identified for this design are
1) Authentication Filters
2) Logging and Auditing Filters
3) Image conversion Filters
4) Data compression Filters
5) Encryption Filters
6) Tokenizing Filters
7) Filters that trigger resource access events
8) XSL/T filters
9) Mime-type chain Filter
| Modifier and Type | Method and Description |
|---|---|
| public default void | |
| public void | doFilter(ServletRequest
The request to process request, ServletResponse The response associated with the request response, FilterChain Provides access to the next filter in the chain for this filter to pass the request and response
to for further processing chain)The |
| public default void | init(FilterConfig
The configuration information associated with the filter instance being initialised filterConfig)Called by the web container to indicate to a filter that it is being placed into service. |
| destroy | back to summary |
|---|---|
| public default void destroy() Called by the web container to indicate to a filter that it is being taken out of service. This method is only
called once all threads within the filter's doFilter method have exited or after a timeout period has passed.
After the web container calls this method, it will not call the doFilter method again on this instance of the
filter. | |
| doFilter | back to summary |
|---|---|
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException The
A typical implementation of this method would follow the following pattern:-
| |
| init | back to summary |
|---|---|
| public default void init(FilterConfig filterConfig) throws ServletException Called by the web container to indicate to a filter that it is being placed into service. The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work. The web container cannot place the filter into service if the init method either:
| |