W3C home > Mailing lists > Public > www-jigsaw@w3.org > March to April 2000

Re: Number of users logged

From: Wes Biggs <wes@cacas.org>
Date: Thu, 2 Mar 2000 10:54:25 -0800 (PST)
To: Walter do Valle <walter@softplan.com.br>
cc: www-jigsaw@w3.org
Message-ID: <Pine.LNX.4.10.10003021048090.9432-100000@xerxes>
If you want the number of concurrent requests to a particular servlet, I
would suggest you declare it as an application-scope variable.  At the
beginning of your service method, increment a counter, at the end,
decrement it:

ServletContext application = getServletContext();
Integer count = null;
synchronized (application) {
  count = (Integer) application.getAttribute("countMyServlet");
  if (count == null) count = new Integer(1);
  else count = new Integer(count.intValue() + 1);
  application.setAttribute("countMyServlet", count);
}
 // bulk of service()/doGet()/doPost() here
synchronized (application) {
  count = new Integer(count.intValue() - 1);
  application.setAttribute("countMyServlet", count);
}

I would put the decrement operation in a finally {} clause to be safe.

Wes

     Because this integrity cannot be altered, the guaranteed e-mail
     of communication can be electronically.

On Thu, 2 Mar 2000, Walter do Valle wrote:

> 
> Hello list
> 
> I am developing a servlet that generates a consult accessing a DB2
> database. My web server is JigSaw. My question is: is it possible my
> servlet count the number os users accessing my servlet? Have JigSaw any
> parameter that "tell" me how much users are accessing it at same time?
> 
> Thank you for all.
> 
> Hugs 
> 
> Walter
> 
Received on Thursday, 2 March 2000 14:05:58 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:14:06 UTC