FileDocCategorySizeDatePackage
ConLimitFilter.javaAPI DocExample800Sat Apr 23 22:35:38 BST 2005None

ConLimitFilter

public class ConLimitFilter extends Object implements Filter

Fields Summary
int
limit
int
count
Constructors Summary
Methods Summary
public voiddestroy()

 
public voiddoFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)

		if ( count > limit ) {
			HttpServletResponse httpRes = (HttpServletResponse)res;
			httpRes.sendError( httpRes.SC_SERVICE_UNAVAILABLE, "Too Busy.");
		} else {
			++count;
			chain.doFilter( req, res );
			--count;
		}
    
public voidinit(javax.servlet.FilterConfig filterConfig)

		String s = filterConfig.getInitParameter("limit");
		if ( s == null )
			throw new ServletException("Missing init parameter: "+limit);
		limit = Integer.parseInt( s );