It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:include and flushing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:include and flushing" Watch "jsp:include and flushing" New topic

jsp:include and flushing

Jerry Bustamente
Ranch Hand

Joined: May 24, 2004
Posts: 90
If a page is buffered and jsp:include is executed with flush=true, the buffer is flushed prior to the inclusion of the included resource.

But what happens when a page is not buffered and jsp:include is executed with flush=true?

Is the buffer flush executed anyway? Is an illegalStateException thrown?

Thanks for your help.


Jerry Bustamente
Jay Tse

Joined: Aug 12, 2005
Posts: 11
If a page is not buffered, (i.e. directive used is <%@page buffer="none"%>
then all the output to the JspWriter is automatically written to out and there is no need of flushing since there is no buffer to flush.

In this case, the flush=true does not make a difference.
An IllegalStateException is not thrown with <jsp:include>, it is only thrown with <jsp:forward> and RequestDispatcher.forward if the buffer is flushed (i.e. response is commited).

This brings up an interesting question the answer to which I don't know.
What if the page is buffered (which is the default for JSP pages with buffer size="8kb") and autoFlush="true" ?(which is also the default) In this case what if the buffer is automatically flushed by the container (because the buffer has grown to a size > "8kb") and then a <jsp:forward> or RequestDispatcher.forward is executed? Will this result in an IllegalStateException even though the user has not commited/flushed the response?

Sorry I'm answering your question with another question and making it more confusing.

I would appreciate it if someone would answer this query I have. (BTW, I'm not sure if this kind of question can be on the exam - its really tricky - I hope not)
I agree. Here's the link:
subject: jsp:include and flushing
It's not a secret anymore!