public abstract class HttpFilter
extends java.lang.Object
implements javax.servlet.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(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpSession session,
javax.servlet.FilterChain chain)
Filter the HTTP request.
|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
protected javax.servlet.FilterConfig |
getFilterConfig()
Returns the filter config.
|
protected java.lang.String |
getInitParameter(java.lang.String name)
Returns the value of the filter init parameter associated with the given name.
|
protected javax.servlet.ServletContext |
getServletContext()
Returns the servlet context.
|
void |
init()
Convenience init() method without FilterConfig parameter which will be called by init(FilterConfig).
|
void |
init(javax.servlet.FilterConfig filterConfig)
Called by the servlet container when the filter is about to be placed into service.
|
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.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 javax.servlet.Filterjavax.servlet.ServletExceptionpublic void init()
public void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws javax.servlet.ServletException,
java.io.IOException
doFilter in interface javax.servlet.Filterjavax.servlet.ServletExceptionjava.io.IOExceptionpublic abstract void doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpSession session,
javax.servlet.FilterChain chain)
throws javax.servlet.ServletException,
java.io.IOException
null if there is no session.javax.servlet.ServletExceptionjava.io.IOExceptionFilter.doFilter(ServletRequest, ServletResponse, FilterChain)public void destroy()
destroy in interface javax.servlet.Filterprotected javax.servlet.FilterConfig getFilterConfig()
protected java.lang.String getInitParameter(java.lang.String name)
name - The filter init parameter name to return the associated value for.protected javax.servlet.ServletContext getServletContext()