Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:include and flushing

 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Sincerely,

Jerry Bustamente
 
Jay Tse
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic