Class IncludeExcludeBasedFilter
java.lang.Object
org.eclipse.jetty.ee9.servlets.IncludeExcludeBasedFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
- Direct Known Subclasses:
HeaderFilter
Include Exclude Based 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(jakarta.servlet.ServletRequest, jakarta.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 exclude
Path spec rules:
- If the spec starts with
'^'the spec is assumed to be a regex based path spec and will match with normal Java regex rules. - If the spec starts with
'/'the spec is assumed to be a Servlet url-pattern rules path spec for either an exact match or prefix based match. - If the spec starts with
'*.'the spec is assumed to be a Servlet url-pattern rules path spec for a suffix based match. - All other syntaxes are unsupported.
CSVs are parsed with StringUtil.csvSplit(String)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()protected StringguessMimeType(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) voidinit(jakarta.servlet.FilterConfig filterConfig) protected booleanshouldFilter(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jakarta.servlet.Filter
doFilter
-
Constructor Details
-
IncludeExcludeBasedFilter
public IncludeExcludeBasedFilter()
-
-
Method Details
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Filter- Throws:
jakarta.servlet.ServletException
-
guessMimeType
protected String guessMimeType(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) -
shouldFilter
protected boolean shouldFilter(jakarta.servlet.http.HttpServletRequest httpRequest, jakarta.servlet.http.HttpServletResponse httpResponse) -
destroy
public void destroy()- Specified by:
destroyin interfacejakarta.servlet.Filter
-
toString
-