org.displaytag.filter
Class ResponseOverrideFilter

java.lang.Object
  extended by org.displaytag.filter.ResponseOverrideFilter
All Implemented Interfaces:
javax.servlet.Filter

public class ResponseOverrideFilter
extends java.lang.Object
implements javax.servlet.Filter

Allow the author of an included JSP page to reset the content type to something else (like a binary stream), and then write the new info back as the exclusive response, clearing the buffers of all previously added content.

This filter allows TableTag users to perform exports from pages that are run as includes, such as from Struts or a jsp:include. If that is your intention, just add this Filter to your web.xml and map it to the appropriate requests, using something like:

  <filter>
      <filter-name>ResponseOverrideFilter</filter-name>
      <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>ResponseOverrideFilter</filter-name>
      <url-pattern>*.do</url-pattern>
  </filter-mapping>
  <filter-mapping>
      <filter-name>ResponseOverrideFilter</filter-name>
      <url-pattern>*.jsp</url-pattern>
  </filter-mapping>
 

By default the filter buffers all the export content before writing it out. You can set an optional parameter buffer to false to make the filter write directly to the output stream. This could be faster and uses less memory, but the content length will not be set.

  <filter>
      <filter-name>ResponseOverrideFilter</filter-name>
      <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
      <init-param>
          <param-name>buffer</param-name>
          <param-value>false</param-value>
      </init-param>
  </filter>
  

Version:
$Revision: 1081 $ ($Author: fgiust $)
Author:
rapruitt, Fabrizio Giustina

Constructor Summary
ResponseOverrideFilter()
           
 
Method Summary
 void destroy()
          
 void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)
          
 void init(javax.servlet.FilterConfig filterConfig)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResponseOverrideFilter

public ResponseOverrideFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)

Specified by:
init in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest servletRequest,
                     javax.servlet.ServletResponse servletResponse,
                     javax.servlet.FilterChain filterChain)
              throws java.io.IOException,
                     javax.servlet.ServletException

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

destroy

public void destroy()

Specified by:
destroy in interface javax.servlet.Filter


Copyright © 2002-2007 the Displaytag team. All Rights Reserved.