FileDocCategorySizeDatePackage
InitCounter.javaAPI DocExample817Tue Jan 25 10:45:14 GMT 2000None

InitCounter

public class InitCounter extends HttpServlet

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

    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();
    count++;
    out.println("Since loading (and with a possible initialization");
    out.println("parameter figured in), this servlet has been accessed");
    out.println(count + " times.");
  
public voidinit(javax.servlet.ServletConfig config)

    super.init(config);
    String initial = config.getInitParameter("initial");
    try {
      count = Integer.parseInt(initial);
    }
    catch (NumberFormatException e) {
      count = 0;
    }