Decorator Filter ver. 1.3

This is a Java servlet filter (as per Servlet API 2.3). DecoratorFilter lets you add dynamically (on the fly) some content to the serviced requests. More precisely filter adds content from the given file before or after the given HTML tag (e.g. before the body tag, or after the head tag etc.)

How to use it:

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

b) describe this filter in web.xml. There is one mandatory initial parameter data describes your file (e.g. with CSS or Javascript) and three optional parameters. Parameter tag describes a tag. Default value is body. Parameter place describes a place for new content (relatively to the given tag). Possible values are before, after or inside. Default value is before. Parameter encoding describes an encoding for data. Default value is UTF-8.
 


<filter>
  <filter-name>DecoratorFilter</filter-name>
  <filter-class>com.cj.decorator.DecoratorFilter</filter-class>
  <init-param>
    <param-name>data</param-name>
    <param-value>path_to_your_text_file</param-value>
  </init-param>
  <init-param>
    <param-name>tag</param-name>
    <param-value>body</param-value>
  </init-param>
</filter>

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


<filter-mapping>
  <filter-name>DecoratorFilter</filter-name>
  <url-pattern>*.jsp</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 DecoratorFilter will insert data from your file into output before sending it to the client.
 

    For downloading:   decoratorflt.jar
 

 ©  Coldbeans     Comments?

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

Also in JSOS: