You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "H.F.N. den Boer" <ni...@denboer-ims.nl> on 2001/04/18 20:55:57 UTC

init/destroy counter ??

A slight "problem" with some static variables.
There are a number of servlet apps on my webserver.
With one servlet, I can check the status.
However, it seems the initial values of the static variables are reported, also
when I know for sure that I have one or more instances "in the air".

I'm working with;
Win2K server, build 5.00.2195
IIS 5.0, configured with ISAPI filter
JDK1.3.1beta
Tomcat 3.2.1 running as NT service

Below the code of the servlet.

Any ideas ?

Nico

public class SrvltA extends SrvltApp {
  private static boolean accessible = true;
  private static int instances = 0;

  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    instances++;
  }

  public void destroy() {
    if (instances > 0)  instances--;
    if (instances == 0) DbAccess.getDbAccess().dbDisconnect();
    super.destroy();
  }

  public static void setAccessible(boolean newAccessible) {
    accessible = newAccessible;
  }

  public static boolean isAccessible() {
    return accessible;
  }

  public static int getInstances() {
    return instances;
  }
}