Generic preprocessor ver. 1.6


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you preprocess incoming requests right in JSP pages. So each incoming request will be forwarded to some JSP page (provided as a parameter for this filter). This JSP will play a role of preprocessor.

How to use it:

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

b) describe this filter in web.xml. Initial parameter preprocessor describes your JSP page for the preprocessing. An optional initial parameter session describes a name for the session scope attribute. This attribute must be in the session scope in order to run the preprocessor. Without this attribute every page (as per filter mapping) will be preprocessed. An optional attribute oncePerSession lets you invoke preprocessing once per session. E.g.:
 


<filter>
  <filter-name>GenericFilter</filter-name>
  <filter-class>com.cj.genericflt.GenericFilter</filter-class>
  <init-param>
   <param-name>preprocessor</param-name>
   <param-value>your_page.jsp</param-value>
  </init-param>
  <init-param>
   <param-name>oncePerSession</param-name>
   <param-value>true</param-value>
  </init-param>
</filter>

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


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

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

And now when you invoke any .jsp page: http://your_host/your_page.jsp GenericFilter will forward request to your JSP page provided in parameter preprocessor. This page is a normal JSP page where you can do whatever you need with incoming requests. As soon as your preprocessing will be completed the normal chain for your request will be restored.

In your JSP preprocessor you may use Preprocessor taglib for getting the original URI and terminating request's chain.

   For downloading:
    Filter:  genericflt.jar

 ©  Coldbeans     Comments?

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

     

Also in JSOS: