Sessions filter ver. 1.3


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you restrict the amount for concurrent HTTP sessions. So, you may use it for example as an access restriction tool, for load balancing etc. You have to use this filter together with Sessions stats listener (it must be installed too).

filter accepts three initial parameters:
limit - describes a maximal amount allowed sessions
redirect - describes an URI for page (site) bounced requests will be redirected to
exclude - optional parameter. Describes a commas separated list of files (URI's) excluded from the processing. By default is empty.

How to use it:

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

b) describe this filter in web.xml. E.g.:
 


<filter>
  <filter-name>SessionsFilter</filter-name>
  <filter-class>com.cj.sesslist.SessionsFilter</filter-class>
  <init-param>
    <param-name>limit</param-name>
    <param-value>30</param-value>
  </init-param>
  <init-param>
    <param-name>redirect</param-name>
    <param-value>/overloaded.jsp</param-value>
  </init-param>
</filter>

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


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

(in this case filter will be on for the each file on your site)

In this example filter allows up to 30 sessions and bounced requests will be forwarded to /overloaded.jsp. If URL for redirection starts with http than filter redirects request, otherwise filter assumes a local resource and forwards request.

   For downloading:

    Sessions filter:  sesslist.jar
 

 ©  Coldbeans     Comments?

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

Also in JSOS: