On 25/07/2011 19:23, Sudeep Pradhan wrote:
> Hi,
> 
> I am using CometProcessor to stream event notifications from server to 
> client. The events are generated at random.  I want to send the notification 
> with Transfer Encoding as chunked so that I can use Apache's 
> ChunkedInputStream to parse the output.
> 
> I get the PrintWriter from the ServletResponse using the getWriter() and I 
> write the event notification on this writer. I want this to be in chunk 
> format of length-payload. Currently I do the following:
> 
> PrintWriter writer = connection.getWriter();
> for (int j = 0; j < pendingEvents.length; j++) {
>                                 String eventString = 
> converter.convert(pendingEvents[j]);
>                                 eventString.concat("\r\n");
>                                 final String length = 
> Integer.toHexString(eventString.length());
>                                 writer.print("\r\n" + length + "\r\n");
>                                 writer.print(eventString);
>                                 //logger.info("Writing:" + eventString);
> }
> 
> But this generates a Bad Chunk size exception on client.

Just write and flush the content. Tomcat will handle the chunking for you.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to