public abstract class HttpFilter extends 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 every time 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 String |
getInitParameter(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. It's recommended to not
override this method. Instead, just use init()
method. When overriding this method anyway, don't forget
to call super.init(config)
, otherwise the getter methods will throw an illegal state exception.init
in interface javax.servlet.Filter
javax.servlet.ServletException
public void init() throws javax.servlet.ServletException
javax.servlet.ServletException
- When filter's initialization failed.public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws javax.servlet.ServletException, IOException
doFilter
in interface javax.servlet.Filter
javax.servlet.ServletException
IOException
public 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, IOException
null
if there is no session.javax.servlet.ServletException
IOException
Filter.doFilter(ServletRequest, ServletResponse, FilterChain)
public void destroy()
destroy
in interface javax.servlet.Filter
protected javax.servlet.FilterConfig getFilterConfig()
protected String getInitParameter(String name)
name
- The filter init parameter name to return the associated value for.protected javax.servlet.ServletContext getServletContext()
Copyright © 2012–2014 OmniFaces. All rights reserved.