1.My understanding is that the less buffer size that you use, the performance is better for client side browsers. Does my assumption correct? If you think otherwise, please explain
Answer: Yes, not actually in terms of performance. But in terms of rendering the content. Because the client will get data at faster rate. Buffer size should be greater than or equal to the underlying socket buffer size. Otherwise, though the jsp's flushes when the buffer size is reached it will not be actually written to the client.
2.What should be the optimal buffer size
Answer: As I have said above it should be greater than or equal the underlying socket buffer size. The optimal size also depends on your application. It should be such a value that once the buffer size is reached, the response will be committed and you can no more do operation which result in adding response header.
3.Is there a way to know what is the default buffer size?
Answer : Yes , by using JspWriter class. JspWriter has a getter getBufferSize()
which gives you the buffer size. The JspWriter can be obtained using pageContext.getOut()
.
4.Setting autoflush to true should flush the buffer once the max size reached. If you set it to false, its upto you to decide when to flush
Answer: If set to true, it will flush when the max buffer size is reached. If set to false, it will throw an exception