Traffic filter ver. 1.4


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you add automatic filtering of traffic to your web-site. TrafiicFilter lets you prohibit access to your site for clients with excessive hits. More detailed: as soon as some IP address during the given time interval produces more than the given amount of hits than access for this IP address will be closed for some time. This time interval as well as allowed hits per interval and ban time all are parameters for TrafficFilter.

How to use it:

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

b) describe this filter in web.xml. Parameters are:

  interval describes a test interval in seconds. Default value is 10.
  counter describes a maximal value for hits per interval. Default value is 8.
  time access closing time in seconds. Default value is 600.
  page optional parameter. All canceled requests will be redirected to this page. By default this parameter is empty and filter will return HTTP status 503 (service unavailable) for all canceled requests.
 


<filter>
  <filter-name>TrafficFilter</filter-name>
  <filter-class>com.cj.traffic.TrafficFilter</filter-class>
  <init-param>
    <param-name>interval</param-name>
    <param-value>10</param-value>
  </init-param>
  <init-param>
    <param-name>counter</param-name>
    <param-value>15</param-value>
  </init-param>
  <init-param>
    <param-name>time</param-name>
    <param-value>600</param-value>
  </init-param>
</filter>

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


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

in this case filter will be on for the each .jsp file. In this example filter allows no more than 15 requests per 10 seconds and closes access to site for 600 seconds.

You can use Traffic taglib for getting info about the banned hosts in your JSP page.

   For downloading:

    Traffic filter:  trafficflt.jar

 ©  Coldbeans     Comments?

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

Also in JSOS: