Hi, I am trying to run the comet sample given along with tomcat. The sample is not working correctly most of the time. I am using NIO connectors and Tomcat version is 6.0.10. I have some doubts also:
1) In the ChatServer example, a thread (using a Runnable MessageSender) is sending responses the clients. Is it possible to write multiple times to the same response. Because when we do writer.flush() then that response is sent to the client. 2) The READ event is never invoked in my example. whenever I send a request only BEGIN event is getting called. I thought, for the first time only BEGIN event should get called, and for further requests by the same client, READ event should get called. 3) I am getting exception at the line where the thread which is trying to write to response stream is calling the flush method. The code (from tomcat example) is: for (int i = 0; i < connections.size(); i++) { try { PrintWriter writer = connections.get(i).getWriter(); String toBeFlushed = ""; for (int j = 0; j < pendingMessages.length; j++) { // FIXME: Add HTML filtering writer.println(pendingMessages[j] + "<br/>"); } writer.println("Random message 1" + "<br/>"); writer.println("Random message 2" + "<br/>"); System.out.println("writer will flush now. writer is null?=" + writer == null); writer.flush(); } catch (IOException e) { log("IOExeption sending message", e); } } And the error message I am getting is: Exception in thread "MessageSender[/CometTestApp]" java.lang.NullPointerException at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:607) at org.apache.coyote.http11.InternalNioOutputBuffer.commit(InternalNioOutputBuffer.java:600) at org.apache.coyote.http11.Http11NioProcessor.action(Http11NioProcessor.java:1010) at org.apache.coyote.Response.action(Response.java:183) at org.apache.coyote.Response.sendHeaders(Response.java:379) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:305) at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288) at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:95) at com.headstrong.test.ChatServlet$MessageSender.run(ChatServlet.java:276) at java.lang.Thread.run(Thread.java:595) -- View this message in context: http://www.nabble.com/Comet-example-Tomcat-6-not-working.-tf3957585.html#a11229741 Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]