Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

flush !

 
yogen joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I was reading the jsp specs, and came across the <jsp:include> & this is what it says about flush,

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.

I did not quite understand this.
Consider the following 4 different cases,

case1.jsp.
<%@ page language='java' autoflush='true' %>
-- --
jsp code
-- --
<jsp:include page='blah.jsp' flush='false' />

case2.jsp.
<%@ page language='java' autoflush='true' %>
-- --
jsp code
-- --
<jsp:include page='blah.jsp' flush='true' />

case3.jsp
<%@ page language='java' autoflush='false' %>
-- --
jsp code
-- --
<jsp:include page='blah.jsp' flush='true' />

case4.jsp
<%@ page language='java' autoflush='false' %>
-- --
jsp code
-- --
<jsp:include page='blah.jsp' flush='false' />

Can anyone please give me the answer to what will happen in each case.
Thanks in advance.
yogen
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi yogen,

autoFlush attribute controls the behavior of the JSP container when the page's output buffer becomes full.If this attribute is set to true(default),the output buffer will automatically be flushed,and its current contents will be sent to the Http server for transmission to the requesting web browser.Page processing then resumes,with any and all new content being buffered until the buffer once again becomes full,or the end of the page is reached.

Case1:
<%@ page language='java' autoflush='true' %>
This means when the buffer is full data should be sent to the client! suppose the buffer size is set to
buffer="9kb" now the output will be temporarily stored in the buffer till it is full once it is full data will be sent to the client..
-- -- DATA---------
<jsp:include page='blah.jsp' flush='false' />
This means include the output of blah.jsp without flushing the prior data in the buffer (without sending the prior data in the buffer to the client).
Note: In this case include action is NOT forcing the buffer to be flushed.Here the buffer will be flushed only when it is full or flushed explicitly.
---------------------------------------------
case2.jsp.
<%@ page language='java' autoflush='true' %>
-- -- SAME as BEFOFE! -- --
-----Data
<jsp:include page='blah.jsp' flush='true' />
This means first flush the buffer(send the data already present in the buffer to the client)even if the buffer is not full and then include the output of blah.jsp...
Note: Here include action is forcing the buffer to be flushed before including the output of blah.jap.

--------------------------------------------------

case3.jsp
<%@ page language='java' autoflush='false' %>
In this case the JSP container WILL NOT automatically flush the buffer when it becomes full. Instead it will raise an exception, which will have the effect of halting processing of the JSP page and displaying an error page in the browser that originally requested the page.
Note:
1-- It is illegal to set the autoFlush attribute to “false” when the buffer attribute is set to “none”.
2—Exception will be raised only when the buffer is full.
-- --
jsp code
-- --
<jsp:include page='blah.jsp' flush='true' />
This means BEFORE including the output of blah.jsp flush the buffer (send the data (prior data in the the buffer)to the client ----).
Note: This would only work if there was no exception raised before this action was used ( the buffer was not full.)

Case4 is for u to Guess!
 
yogen joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Amer,
I got it.
yogen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic