public abstract class HttpFilter extends Object implements Filter
doFilter()
method providing the
HTTP servlet request, response and session so that there's no need to cast them everytime. Also, default
implementations of init(FilterConfig)
and destroy()
are provided, so that there's no need to
implement them everytime even when not really needed.Constructor and Description |
---|
HttpFilter() |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
abstract void |
doFilter(HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
FilterChain chain)
Filter the HTTP request.
|
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain) |
protected FilterConfig |
getFilterConfig()
Returns the filter config.
|
protected String |
getInitParameter(String name)
Returns the value of the filter init parameter associated with the given name.
|
protected ServletContext |
getServletContext()
Returns the servlet context.
|
void |
init()
Convenience init() method without FilterConfig parameter which will be called by init(FilterConfig).
|
void |
init(FilterConfig filterConfig)
Called by the servlet container when the filter is about to be placed into service.
|
public void init(FilterConfig filterConfig) throws ServletException
FilterConfig
object for later use by the getter methods. When overriding this method, call
super.init(config)
, otherwise the getter methods will throw an illegal state exception.init
in interface Filter
ServletException
public void init() throws ServletException
ServletException
- When filter's initialization failed.public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException
doFilter
in interface Filter
ServletException
IOException
public abstract void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) throws ServletException, IOException
null
if there is no session.protected FilterConfig getFilterConfig()
protected String getInitParameter(String name)
name
- The filter init parameter name to return the associated value for.protected ServletContext getServletContext()