Sun GlassFish Enterprise Server v3 Prelude Developer's Guide

ProcedureRegistering the Servlet with the Comet Engine

  1. In the servlet's init method, add the following code to get the component's context path:

    ServletContext context = config.getServletContext();
    contextPath = context.getContextPath() + "/hidden_comet";
  2. Get an instance of the Comet engine by adding this line after the lines from step 1:

     CometEngine engine = CometEngine.getEngine();
  3. Register the component with the Comet engine by adding the following lines after those from step 2:

    CometContext cometContext = engine.register(contextPath);
    cometContext.setExpirationDelay(30 * 1000);