public class MutableRequestFilter extends HttpFilter
The MutableRequestFilter will wrap the incoming HttpServletRequest in a MutableRequestFilter.MutableRequest so
that the developer can mutate the headers and parameters in such way that the outcome of among others
HttpServletRequest.getHeader(String) and ServletRequest.getParameter(String) are influenced.
To get this filter to run, map it as follows in web.xml:
<filter>
<filter-name>mutableRequestFilter</filter-name>
<filter-class>org.omnifaces.filter.MutableRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>mutableRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The ordering of the <filter-mapping> is significant. The MutableRequestFilter.MutableRequest is not available
in any filter which is mapped before the MutableRequestFilter.
When inside FacesContext, use Faces.getMutableRequestHeaderMap() or
Faces.getMutableRequestParameterMap().
Or when having only a HttpServletRequest at hands, use
Servlets.getMutableRequestHeaderMap(HttpServletRequest) or
Servlets.getMutableRequestParameterMap(HttpServletRequest).
HttpFilter,
MutableRequestFilter.MutableRequest| Modifier and Type | Class and Description |
|---|---|
static class |
MutableRequestFilter.MutableRequest |
| Modifier and Type | Field and Description |
|---|---|
static String |
MUTABLE_REQUEST
The name of the request attribute under which the
MutableRequestFilter.MutableRequest will be stored. |
| Constructor and Description |
|---|
MutableRequestFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
doFilter(HttpServletRequest request,
HttpServletResponse response,
HttpSession session,
FilterChain chain)
Creates and sets the mutable request.
|
static MutableRequestFilter.MutableRequest |
getMutableRequest(HttpServletRequest request)
Returns the mutable request.
|
void |
init()
Tracks whether this filter is installed.
|
destroy, doFilter, getFilterConfig, getInitParameter, getServletContext, initpublic static final String MUTABLE_REQUEST
MutableRequestFilter.MutableRequest will be stored.public void init()
throws ServletException
init in class HttpFilterServletException - When filter's initialization failed.public void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) throws ServletException, IOException
doFilter in class HttpFilterrequest - The HTTP request.response - The HTTP response.session - The HTTP session, if any, else null.chain - The filter chain to continue.ServletException - As wrapper exception when something fails in the request processing.IOException - Whenever something fails at I/O level.Filter.doFilter(ServletRequest, ServletResponse, FilterChain)public static MutableRequestFilter.MutableRequest getMutableRequest(HttpServletRequest request)
IllegalStateException - When the MutableRequestFilter is not installed or not invoked yet.Copyright © 2012–2022 OmniFaces. All rights reserved.