import com.sun.grizzly.tcp.http11.GrizzlyAdapter; import com.sun.grizzly.tcp.http11.GrizzlyRequest; import com.sun.grizzly.tcp.http11.GrizzlyResponse; public class MyAdapter extends GrizzlyAdapter { public MyAdapter(String string) { // TODO Auto-generated constructor stub } @Override public void service(GrizzlyRequest req, GrizzlyResponse res) { String uri = req.getRequestURI(); Session s = Session.get("something on cookie :D"); if (uri.endsWith("push")) { String resp= s.handlePush(); try { res.setStatus(200); res.setContentType("text/xml"); res.setContentLength(resp.length()); res.getWriter().println(resp); } catch (Exception e) { e.printStackTrace(); } } } }