使用jetty实现服务器端推的技术

public class ContinuationServlet extends HttpServlet {

	  public void service(HttpServletRequest req, HttpServletResponse res)
	                                              throws java.io.IOException {

	    String reqId = req.getParameter("id");
	    
	    Continuation cc = ContinuationSupport.getContinuation(req,null);

	    res.setContentType("text/plain");
	    res.getWriter().println("Request: "+reqId+"\tstart:\t"+new Date());
	    res.getWriter().flush();

	    cc.suspend(2000);
	    
	    res.getWriter().println("Request: "+reqId+"\tend:\t"+new Date());
	  }
	}

相关的文章:

http://www.ibm.com/developerworks/cn/java/j-jettydwr/

http://www.ibm.com/developerworks/cn/java/j-lo-comet/

你可能感兴趣的:(使用jetty实现服务器端推的技术)