Why do I need to modify buffer and autoflush attributes in a JSP?

你。 提交于 2019-12-14 03:59:52

问题



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?


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/17402792/why-do-i-need-to-modify-buffer-and-autoflush-attributes-in-a-jsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!