Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

jsp:include and flushing

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic