JSP和autoflush属性的最佳缓冲区大小 [英] Optimal buffer size for JSP's and autoflush property

查看:135
本文介绍了JSP和autoflush属性的最佳缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人建议设置JSP的最佳缓冲区大小吗?您可以使用以下页面指令在JSP的

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" %>

我的问题如下

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

  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

最佳缓冲区大小应该是什么

What should be the optimal buffer size

有没有办法知道默认的缓冲区大小是什么?

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

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

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.我的理解是,使用的缓冲区大小越小,客户端浏览器的性能越好.我的假设正确吗?否则,请解释

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

这篇关于JSP和autoflush属性的最佳缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆