File access filter ver. 1.3

This is a Java servlet filter (as per Servlet API 2.3). This filter lets you protect some files on your server (web application) from the direct access. For example in your Struts application you need to prohibit the direct access to JSP files etc.

How to use it:

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

b) describe this filter in web.xml. Filter accepts two initial parameters. Parameter protect describes a commas separated list of extensions for protected files. Parameter exclude describes a commas separated list of files where direct access is allowed (in other words being excluded from the protection schema).
Both parameters are optional. Default value for protect is jsp. In other words by default filter protects direct access to JSP files. Default value for exclude is index.jsp. In other words by default filter keeps direct access to index.jsp file.
 


<filter>
  <filter-name>FileAccessFilter</filter-name>
  <filter-class>com.cj.fileaccess.FileAccessFilter</filter-class>
</filter>

or (close JSP and HTML files for example):
 


<filter>
  <filter-name>FileAccessFilter</filter-name>
  <filter-class>com.cj.fileaccess.FileAccessFilter</filter-class>
  <init-param>
    <param-name>protect</param-name>
    <param-value>jsp,html,htm</param-value>
  </init-param>
</filter>

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


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

in this example filter will be on for the each file on your server.

Note: filter returns HTTP code 403 for protected files.

   For downloading:

    File access package:  fileaccessflt.jar
 

 ©  Coldbeans     Comments?

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

Also in Coldtags: