javax.servlet.Filter
HeaderFilter
public abstract class IncludeExcludeBasedFilter
extends java.lang.Object
implements javax.servlet.Filter
This is an abstract filter which helps with filtering based on include/exclude of paths, mime types, and/or http methods.
Use the shouldFilter(HttpServletRequest, HttpServletResponse)
method to determine if a request/response should be filtered. If mime types are used,
it should be called after FilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
since the mime type may not
be written until then.
Supported init params:
includedPaths
- CSV of path specs to includeexcludedPaths
- CSV of path specs to excludeincludedMimeTypes
- CSV of mime types to includeexcludedMimeTypes
- CSV of mime types to excludeincludedHttpMethods
- CSV of http methods to includeexcludedHttpMethods
- CSV of http methods to excludePath spec rules:
'^'
the spec is assumed to be a regex based path spec and will match with normal Java regex rules.'/'
the spec is assumed to be a Servlet url-pattern rules path spec for either an exact match or prefix based
match.'*.'
the spec is assumed to be a Servlet url-pattern rules path spec for a suffix based match.
CSVs are parsed with StringUtil.csvSplit(String)
PathSpecSet
,
IncludeExcludeSet
Constructor | Description |
---|---|
IncludeExcludeBasedFilter() |
Modifier and Type | Method | Description |
---|---|---|
void |
destroy() |
|
protected java.lang.String |
guessMimeType(javax.servlet.http.HttpServletRequest http_request,
javax.servlet.http.HttpServletResponse http_response) |
|
void |
init(javax.servlet.FilterConfig filterConfig) |
|
protected boolean |
shouldFilter(javax.servlet.http.HttpServletRequest http_request,
javax.servlet.http.HttpServletResponse http_response) |
|
java.lang.String |
toString() |
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
javax.servlet.ServletException
protected java.lang.String guessMimeType(javax.servlet.http.HttpServletRequest http_request, javax.servlet.http.HttpServletResponse http_response)
protected boolean shouldFilter(javax.servlet.http.HttpServletRequest http_request, javax.servlet.http.HttpServletResponse http_response)
public void destroy()
destroy
in interface javax.servlet.Filter
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1995–2017 Webtide. All rights reserved.