问题
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