tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: How can I count the number of active requests/servlets for Tomcat?
Date Thu, 15 Jan 2004 23:58:59 GMT

> I'm running a web service using Axis with Tomcat.  How can I count 
> the number of active requests?

I think you want to use a Filter for your requests:

public class ConnectionCounter
	implements javax.servlet.Filter
	private int _activeConnections = 0;

	public void init(FilterConfig fc) { }
	public void destroy() { }
	public doFilter(ServletRequest req,
			ServletResponse rsp,
			FilterChain fc)
		throws ServletException, IOException
		synchronized(this) {


		synchronized(this) {

	public int getActiveConnectionCount()
		// Need not be synchronized, int access is atomic
		return _activeConnections;

Of course, you'll need to get a reference to your filter in order to
read the connection count, but that is an exercise left to the reader :)

> I used the HttpListener interace but the sessionDestroyed method
> doesn't seem to get called until 5 minutes after the servlet ends.

Ouch. You have web services that use sessions? You should probably turn 
off http sessions for those...


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message