且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSP和autoflush属性的***缓冲区大小

更新时间:2023-11-07 23:46:28

1.我的理解是,使用的缓冲区大小越小,客户端浏览器的性能越好.我的假设正确吗?否则,请解释

答案:是的,实际上并不是在性能方面.但是就渲染内容而言.因为客户端将以更快的速度获取数据.缓冲区大小应大于或等于基础套接字缓冲区的大小.否则,尽管在达到缓冲区大小时jsp会刷新,但实际上不会写入客户端.

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.***缓冲区大小应该是什么

答案:如上所述,它应该大于或等于基础套接字缓冲区的大小.***大小还取决于您的应用程序.该值应这样,一旦达到缓冲区大小,响应将被提交,并且您不能再执行任何操作来添加响应头.

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.是否有办法知道默认的缓冲区大小是什么?

答案:是,通过使用JspWriter类. JspWriter有一个getter getBufferSize(),它为您提供了缓冲区的大小.可以使用pageContext.getOut()获得JspWriter.

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.将autoflush设置为true会在达到最大大小后刷新缓冲区.如果将其设置为false,则由您决定何时刷新

答案:如果设置为true,则在达到最大缓冲区大小时将刷新.如果设置为false,它将引发异常

Answer: If set to true, it will flush when the max buffer size is reached. If set to false, it will throw an exception