Question

Some documentation on Oracle's website (http://docs.oracle.com/cd/A97688_16/generic.903/bp/j2ee.htm, 3.1.12 Disable JSP Page Buffer If Not Used) says:

If you are not using any JSP features that require buffering, you can disable it to improve performance; memory will not be used in creating the buffer, and output can go directly to the browser. You can use the following directive to disable buffering:

<%@ page buffer="none" %>

However, I haven't been able to find any kind of documentation that specifies just what exactly are "JSP features that require buffering." I understand generally under what circumstances decreasing or increasing the buffer may or may not help performance, but what I don't know is what kind of features would "require" buffering.

Under what circumstances should you turn buffering off, and/or under what circumstances should you NOT turn buffering off?

Was it helpful?

Solution

Actually, I just had a "duh" moment. There are things you can do in JSPs that manipulate the headers returned with the response, such as response.setHeader(...) or <jsp:forward />. These obviously must always occur before the response is committed and data starts flowing to the client. If you disabled buffering, you would never be able to set headers or use the forward tag, which may or may not be desirable, because data would start flowing to the client immediately. I don't know why I didn't just think of that...

Basically what it boils down to is whether performance is more important than losing the ability to set headers or use the forward tag. If it is, you'd want to disable buffering. If being able to set headers or use the forward tag is important, you'd want to leave buffering enabled.

If someone can correct me or post a better answer in the next two days, I will happily accept that as the answer, instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top