org.omnifaces.filter
Class OnDemandResponseBufferFilter
java.lang.Object
org.omnifaces.filter.HttpFilter
org.omnifaces.filter.OnDemandResponseBufferFilter
- All Implemented Interfaces:
- javax.servlet.Filter
public class OnDemandResponseBufferFilter
- extends HttpFilter
Filter that wraps the response with one capable of buffering on command.
The response wrapper is additionally make available as a request attribute, so it's always obtainable even if a following filter
wraps the response again. By default the response wrapper is in "pass-through" mode, meaning it will do no buffering. Anywhere during the
request it can be switched to buffer by setting its passThrough
argument to false.
The next call to obtain the response's writer will then provide one that buffers. Do note that any existing writer that has been obtained
before passThrough
was set to false and is used afterwards, will not automatically start buffering. Only newly obtained
writers will buffer from that point on.
If at the end of the request, when this filter resumes control again, the response is still buffering (passThrough
is false)
its buffer will be automatically flushed to the underlying response. If however the buffer is not empty, but passThrough
is true,
no such flushing will be done and it's assumed the application has taken care of this.
- Since:
- 1.2
- Author:
- Arjan Tijms
Method Summary |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BUFFERED_RESPONSE
public static final java.lang.String BUFFERED_RESPONSE
- See Also:
- Constant Field Values
OnDemandResponseBufferFilter
public OnDemandResponseBufferFilter()
doFilter
public 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,
java.io.IOException
- Description copied from class:
HttpFilter
- Filter the HTTP request. The session argument is
null
if there is no session.
- Specified by:
doFilter
in class HttpFilter
- Throws:
javax.servlet.ServletException
java.io.IOException
- See Also:
Filter.doFilter(ServletRequest, ServletResponse, FilterChain)