Sun GlassFish Enterprise Server v3 Application Development Guide

ProcedureTo Add the Comet Handler to the Comet Context

  1. Get an instance of the Comet handler and attach the response to it by adding the following lines to the doGet method:

    CounterHandler handler = new CounterHandler();
    handler.attach(res);
  2. Get the Comet context by adding the following lines to doGet:

    CometEngine engine = CometEngine.getEngine();
    CometContext context = engine.getCometContext(contextPath);
  3. Add the Comet handler to the Comet context by adding this line to doGet:

    context.addCometHandler(handler);