The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What is the use of flush? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "What is the use of flush?" Watch "What is the use of flush?" New topic
Author

What is the use of flush?

Ram Dhan Yadav K
Ranch Hand

Joined: Aug 13, 2001
Posts: 321
Hi,
there is a flush attribute in page directive. i would like to know what is the use of that attribute? what difference does that make to the jsp page? any real time application scenarios where it is used?
thanks,
Ram Dhan Yadav K


Ram Dhan Yadav (SCJP, SCWCD, SCJA-I, IBM EC(483))
"We are what we repeatedly do. Excellence, then, is not an act, but a habit."
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16617

I am not positive if I am right, but isn't flush used to say, hey I am done with the Response object, send it to the client?
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Lemme try in my words.
When the buffer is filled with the specified amount of data, flush is used to clear the buffer and load new data in the same buffer (volatile space) from the same source, so if you have 20kb to pass and set buffer size to 8kb ans set "flush = true" in a JSP page, your 20kb data will be transmitted to the input/output stream chain like (8+8+4)kb to increase performance of the whole transmission.
Correct me if i m wrong.


Ashik Uzzaman
Senior Member of Technical Staff,
Salesforce.com, San Francisco, CA, USA.
Ram Dhan Yadav K
Ranch Hand

Joined: Aug 13, 2001
Posts: 321
Hi Guys,
I guess i found one usage of flush.
Well, let me try to put it in code.
<%@ page ...news paper..%>
<%jsp:include page="article 1" flush="true"%>
<%jsp:include page="article 2" flush="true"%>
<%jsp:include page="article 3" flush="true"%>
<%jsp:include page="article 4" flush="true"%>
<%jsp:include page="article 5" flush="true"%>
Here i am trying to put a rough sketch of a news paper.
When i have to include "article 1", the buffer is flused and then it is included and then when i have to include "article 2", "article 1" is flused and thus client will be able to see the the "article 1" link(s) even while the "article 2" is bieng loaded.
Does that sound realistinc. I guess so. ANy comments are welcome.
thanks,
Ramdhan Yadav K
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Yes Ramdhan. Think so.
In my current perception the underlying PrintWriter Object is a buffered Stream.
So
1. the characters are written to a buffer.
2. the content of the buffer will be written to the target of the Stream (browser of user) if
a) the buffer is full
b) the buffer is flushed with flush()-method.
Any comments and corrections welcome.
Axel
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Axel, i agree with u...
Ramadhan, have u tried a code using one of those articles (say article3) declaring flush="false"? I think that would be interesting how it behaves when it comes with next article...
 
 
subject: What is the use of flush?
 
Threads others viewed
flush - jsp:include
Regarding JSP Action flush attribute
jsp:include doubt?
Use of flush Attribute in <jsp:include />
The purpose of flush attribute in jsp:include
IntelliJ Java IDE