Thursday, April 17, 2008

importance of flush attribute in

The flush attribute controls whether any current output is flushed (sent to browser) prior to including the content from the include file. However the JSP 1.1 specificaton is currently limited to only allow true values. This is a limitation that may be relaxed in future specifications.

Important. The fact that we must flush the output buffer limits what we can do with the <jsp:include/> action. In particular, using response.sendRedirect() to another page is no longer possible. Likewise, setting cookies or HTTP Headers will not succeed. This applies to both the files involved: the including file and the file that is included.

 

When you include a JSP into another, you will get a new buffer to be filled.

This means a few things, the least of which is you then have more output in memory (resource eating).

Another 'problem' is that if an error occurs on the included page, then the user will see the error, and not the results of any successful execution of the outside buffer. This could be bad if you want high - responsiveness (quick output that at least appears right) or it might be a bad thing if you want to handle exceptions and errors in special ways.

Most importantly, though, is that the inner buffer (created when you include the JSP) MAY be flushed BEFORE the including page, and things go out of order

 

No comments:

Post a Comment