- All Implemented Interfaces:
Filter
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.
Installation
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.
Usage
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).
- Since:
- 3.14
- Author:
- Bauke Scholtz
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the request attribute under which theMutableRequestFilter.MutableRequestwill be stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) Creates and sets the mutable request.getMutableRequest(HttpServletRequest request) Returns the mutable request.voidinit()Tracks whether this filter is installed.Methods inherited from class org.omnifaces.filter.HttpFilter
destroy, doFilter, getFilterConfig, getInitParameter, getServletContext, init
-
Field Details
-
MUTABLE_REQUEST
The name of the request attribute under which theMutableRequestFilter.MutableRequestwill be stored.- See Also:
-
-
Constructor Details
-
MutableRequestFilter
public MutableRequestFilter()
-
-
Method Details
-
init
Tracks whether this filter is installed.- Overrides:
initin classHttpFilter- Throws:
ServletException- When filter's initialization failed.
-
doFilter
public void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) throws ServletException, IOException Creates and sets the mutable request.- Specified by:
doFilterin classHttpFilter- Parameters:
request- The HTTP request.response- The HTTP response.session- The HTTP session, if any, elsenull.chain- The filter chain to continue.- Throws:
ServletException- As wrapper exception when something fails in the request processing.IOException- Whenever something fails at I/O level.- See Also:
-
getMutableRequest
Returns the mutable request.- Returns:
- The mutable request.
- Throws:
IllegalStateException- When theMutableRequestFilteris not installed or not invoked yet.- Since:
- 3.14
-