Cached Response filter ver. 1.3

This is a Java servlet filter (as per Servlet API 2.3). CachedResponseFilter lets you cache the output and change/resets it in your JSP files. For example, your JSP include decides to drop the already accumulated output and/or change the content type for the output or simply forward the request to another location. That is what CachedResponse is for.

How to use it:

a) download cachedflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml.
 


<filter>
  <filter-name>CachedResponseFilter</filter-name>
  <filter-class>com.cj.cached.CachedResponseFilter</filter-class>
</filter>

You can set also an optional parameter encoding and describe an encoding for the cached chunks:
 


<filter>
  <filter-name>CachedResponseFilter</filter-name>
  <filter-class>com.cj.cached.CachedResponseFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>

c) describe a mapping for this filter in web.xml
 


<filter-mapping>
  <filter-name>CachedResponseFilter</filter-name>
  <url-pattern>*</url-pattern>
</filter-mapping>

in this case filter will be on for the each .jsp file

And now when you invoke any .jsp page: http://your_host/your_page.jsp this filter will cache the output unless the whole request will be processed. So any time in the middle of your processing you can obtain the already accumulated content, reset it or change content type. Custom JSP taglib Cached Response taglib lets you do that right from your JSP pages.

   For downloading:
    Filter:  cachedflt.jar
 

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: