FileDocCategorySizeDatePackage
HolisticCounter.javaAPI DocExample1180Thu Apr 05 01:19:48 BST 2001None

HolisticCounter

public class HolisticCounter extends HttpServlet

Fields Summary
static int
classCount
int
count
static Hashtable
instances
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

  // also shared

       
                                  
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();

    count++;
    out.println("Since loading, this servlet instance has been accessed " +
                count + " times.");

    // Keep track of the instance count by putting a reference to this
    // instance in a Hashtable. Duplicate entries are ignored.
    // The size() method returns the number of unique instances stored.
    instances.put(this, this);
    out.println("There are currently " +
                instances.size() + " instances.");

    classCount++;
    out.println("Across all instances, this servlet class has been " +
                "accessed " + classCount + " times.");