为什么需要在JSP中修改buffer和autoflush属性? [英] Why do I need to modify buffer and autoflush attributes in a JSP?

查看:104
本文介绍了为什么需要在JSP中修改buffer和autoflush属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我不明白为什么我需要修改JSP中的buffer和autoflush属性,它们做什么?如果不修改它们会发生什么?


I don't understand why I need to modify the buffer and autoflush attributes in JSP, what do they do? What could happen if I do not modify them?

推荐答案

JSP页面生成的所有内容都存储在缓冲区中.当缓冲区已满时,它将发送回客户端(浏览器).缓冲区一次刷新后,重定向或转发将不起作用,因为对HTTP响应标头的所有更改都必须在第一次将缓冲区发送到客户端时发生.同样,您不能在第一次刷新后向响应中添加Cookie.

Anything generated by the JSP page is stored in a buffer. When the buffer is full, it's sent back to the client (browser). When the buffer is flushed once, redirection or forwarding won't work because all changes to the HTTP response header must occur the first time a buffer is sent to the client. Similarly you cannot add cookies to the response after the first flush.

表示,您可能希望禁用自动刷新和/或增加缓冲区大小,以使您的代码最近可以将Cookie添加到响应中.但是,如果您需要这样做,则您的代码可能并不优雅.

Said that, you could want to disable autoflushing and/or to increase buffer size to allow your code to add a cookie to the response very lately. However if you need to do so, your code is probably not elegant.

缓冲区大小也会影响性能:请参见 JSP的最佳缓冲区大小和自动刷新属性.

The buffer size also affects performance: see Optimal buffer size for JSP's and autoflush property.

这篇关于为什么需要在JSP中修改buffer和autoflush属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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