well -- Mark surely knows much better than I do -- so take into account
what he wrote, but I was already writing this so I decided to send
anyway, and for most application it should work fine IMO:
1) you create a class that implements the Filter interface and maintains
the count in an AtomicLong object.
2) you increment the AtomicLong before the call to chain.doFilter() and
decrement it after that call.
3) you add a way to get the value, either with a public method or by
setting the value to a Servlet Attribute.
see more about Filters at
http://www.oracle.com/technetwork/java/filters-137243.html
another way I can think of is to get all the threads in the JVM with
Thread.getAllStackTraces(), loop over them, and check their names for
example.
On 7/31/2014 10:01 AM, Mark Thomas wrote:
On 31/07/2014 17:56, Campbell, Lance wrote:
Could you elaborate a little? How do you actually get the number of HTTP
connections?
You can't do this with a Filter. You can determine the number of active
requests for an application but connection != active request and
application != Tomcat server.
There is no standard Servlet API for the information you want.
Mark
Thanks,
Lance Campbell
Software Architect
Web Services at Public Affairs
217-333-0382
-----Original Message-----
From: Igal Sapir [mailto:i...@getrailo.org]
Sent: Thursday, July 31, 2014 11:35 AM
To: Tomcat Users List
Subject: RE: Programmatically retrieve number of tomcat connections
Write a simple ServletFilter
On Jul 31, 2014 9:33 AM, "Campbell, Lance" <la...@illinois.edu> wrote:
Good question. I would like to have a servlet that would return to me
the number of tomcat HTTP connections. I know you can do this via a
Linux console command. But I would prefer to do it via a servlet.
Thanks,
Lance Campbell
Software Architect
Web Services at Public Affairs
217-333-0382
-----Original Message-----
From: Mark Thomas [mailto:ma...@apache.org]
Sent: Thursday, July 31, 2014 11:10 AM
To: Tomcat Users List
Subject: Re: Programmatically retrieve number of tomcat connections
On 31/07/2014 17:06, Campbell, Lance wrote:
Tomcat 7
Is there a way via a Java servlet to get the number of tomcat
connections?
Connections from what to what in what state?
With or without non-Servlet API calls?
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
--
Igal Sapir
Railo Core Developer
http://getRailo.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org