The default size of the response buffer for a Servlet or a JSP is 8k.
When it becomes filled, ServletExec will automatically flush it to the client.
The first flush contains the response headers followed by the response body.
Subsequent flushes contain the remainder of the response body.
If necessary, you can increase the size of the buffer by using a page directive [in a JSP]. For example:
<%@page buffer="2000kb"%> would set the buffer size to ~2mb.
Another way to configure the buffer size is to call response.setBufferSize() [in a servlet or JSP].
This will delay the automatic flushing of the response buffer.
Yet another way to accomplish this (for JSPs only... not Servlets) when using SE 126.96.36.199 (or higher) is described in the ReleaseNotes.txt file that comes with that hotfix. Basically, you'd configure the JspServlet in your webapp, passing the "bufferSizeKb" init parameter.
Please read that file for more details.
Here is one possible way to configure you webapp so that it uses an unlimited response buffer size (this would work for both Servlets and JSPs):
create your own subclass of javax.servlet.ServletResponseWrapper which overrides the methods used to write data to the client. For example the getWriter() method would be overridden to return a writer that caches all data. For example the flushBuffer() method would be overridden to flush the cached data out to the wrapped output stream.
Write a class that implements javax.servlet.Filter which:
wraps the response object using your response wrapper class.
calls chain.doFilter() passing the wrapper
flushes the cached response out to the real/unwrapped output stream
Configure that Filter into your webapp so that it will be invoked for relevant requests.
That way when the requested servlet or JSP calls response.getWriter() it will be getting the wrapped/buffered writer and will be writing to it instead of writing to the real writer.