public interface Filter
Developers must implement this interface for filtering code and
then cause their Filter
s to be mapped to servlets or
url-patterns (normally by using a webapp's deployment descriptor).
When the server loads the filter it causes the init()
method to be called with the necessary config information (including
init parameters, specified in the webapp's DD perhaps).
When the server recieves requests that match the filter conditions
it calls the doFilter()
method of the first matching
filter. The remaining filters (and the target servlet) are passed in
the FilterChain
argument. The developer must call the
FilterChain.doFilter()
method to pass the request on to
the next filter.
When the server has finished with the filter it calls the
destory()
method after the filter has been removed
from use.
For more information see section 6 of the Servlet API 2.3 specification.
for more information on how the chains work
Modifier and Type | Method and Description |
---|---|
void |
destroy()
destroy a filter.
|
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
filter the request/response.
|
void |
init(FilterConfig init)
initialize a filter.
|
void init(FilterConfig init) throws ServletException
init
- the filter's configuration information (including init params)ServletException
void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, java.io.IOException
request
- the request to be filteredresponse
- the response to be filteredchain
- the remaining filters (and the target servlet) in the request chainServletException
java.io.IOException
void destroy()