• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The purpose of flush attribute in jsp:include

 
Naveen Kumar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have a doubt regarding flush attribute .
In <jsp:include page="relativeurl" flush="true" /> what is the purpose of flush attribute here.can we use it in forward tag also??.
can anyone help me.
 
Reesha Ashok
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the jsp 2.0 spec

The flush attribute controls flushing. If true, then, if the page output is buffered and the flush attribute is given a true value, then the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush attribute is false.

forward doesn't let you write something before forwarding. So it's of no use in a forward action
More on the use of flush in include action please read this
discussion
 
Naveen Kumar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
consider this sample coding given by Marc Peabody .

<%
out.write("This will print!<br/>");
out.flush();
out.write("This will also print!<br/>");
out.flush();
out.write("This will get sent to the client too!<br/>");
%>

by default jsp pages are buffered.that means the stuff written to the JspWriter (out) object does not immediately or directly goes to the client through the response.

the character are stored in the buffer and once we flush it everything in the buffer goes to the client through the response object.

but in the above coding. the flush is been used many times.
my doubt is on each time we are invoking the flush method on out object means each time it gets the datas stored in the buffer is sent to the client through the response object??
for example :
flush is used 2 times in the above code.
then response object will be invoked twice??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic