简体   繁体   中英

Optimal buffer size for JSP's and autoflush property

Does anyone have recommendation for setting optimal buffer size for JSP's? You can use the following page directive to set the buffer size in JSP's

    <%@page buffer="xxxkb" autoFlush="true" %>

My questions are the following

  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

  2. What should be the optimal buffer size

  3. Is there a way to know what is the default buffer size?

  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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM