users@grizzly.java.net

Flushing output in http server

From: Peter Speck <speck_at_vitality.dk>
Date: Thu, 22 May 2008 20:03:01 +0200

Hi,

I'm trying to flush the generated html to the client in a lengthy
processing loop, e.g.

response.setHeader("abc", "def");
response.setHeader("ghi", "jki");
response.sendHeaders();

ByteChunk chunk = new ByteChunk();
while (notDone) {
   do_something_that_takes_long_time();
   chunk.setBytes(...);
   response.doWrite(chunk);
}
response.finish();


It seems like the response is not sent to the client until I call
response.finish(). How can I get Grizzly to send the partial content
in response.doWrite()? As the content-length is not known in
advance, I've not called response.setContentLength(). I'm using
Grizzly 1.7.3.3


Thanks in advance,
    - Peter Speck