Default attributes filter ver. 1.2


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you define the default attributes for the request scope.

How to use it:

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

b) describe this filter in web.xml. Initial parameters must describe your default attributes. For example:
 


<filter>
  <filter-name>DefaultAttributeFilter</filter-name>
  <filter-class>com.cj.defattribute.DefAttributeFilter</filter-class>
  <init-param>
    <param-name>intAttribute</param-name>
    <param-value>5</param-value>
  </init-param>
  <init-param>
    <param-name>strAttribute</param-name>
    <param-value>test</param-value>
  </init-param>
</filter>

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


<filter-mapping>
  <filter-name>DefaultAttributeFilter</filter-name>
  <url-pattern>*.jsp</url-pattern>
</filter-mapping>

and now your request will have the above mentioned default attributes intAttribute and strAttribute.

Also you can describe values for your parameters in the following form:

application.some_name

and

session.some_name

in this case filter will lookup some_name attribute in the appropriate scope (application or session) and use its value.

   For downloading:

    Default attributes filter:  defattrflt.jar

 ©  Coldbeans     Comments?

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

Also in JSOS: