On Thu, 2 Mar 2000, Wes Biggs wrote: > 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. Of course, you have to set the lifetime (Servlet Timeout) of the servlet to -1 to avoid the reset of the servlet! Another way would be to add a CounterFilter to the frame of the servlet, but it is related to Jigsaw, so you have to find a way to pass it to the servlet, by extending CounterFilter. /\ - Yves Lafon - World Wide Web Consortium - /\ / \ Architecture Domain - Jigsaw Activity Leader / \ \/\ / \ / \ http://www.w3.org/People/Lafon - ylafon@w3.orgReceived on Friday, 3 March 2000 05:42:51 UTC
This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:41:28 UTC