JSP flush buffer confusion

If i have the below code:

out.write("This will print!<br/>");
out.write("This will also print!<br/>");
out.flush(); <-- Should fail.
out.write("This will get sent to the client too!<br/>");

Why is the second flush being allowed? I thought that a flush will commit a response and being sent to the client. Once a response is commited, you can't write and flush anymore. The first flush commited the response and has sent to the client. So i would expect the second flush to fail.

I also read that for an include on the requestDispatcher, one can flush as many times as you want (but not for a requestDispatcher forward). How is that so?

I'm confused on this and i would appreciate any enlightening. Thanks.


You can do flush many times. A flush called (automatically by container OR manually by code) caused existing data in output buffer sent to client. After first flush, the response is marked committed. We have no chance to write response headers/cookies After response is committed. After each flush, the buffer will be reset for storing data of next content writes. You can do flush manually or container will do flush when the buffer is full or at the end of request.

Need Your Help

android how to stop audio thread on button press?

android multithreading audio audiotrack

I have a thread that uses AudioTrack to synthesize a sequence of notes, with a seekbar to change the tempo.

Is there a C/C++ API to the route information on Windows?

windows routing cygwin routes ipv4

Is there a windows or cygwin C/C++ API to collect information provided by the route command on Windows? I'm specifically interested in the route metrics. Here's an example of what route outputs, ...