• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the use of flush?

 
Ram Dhan Yadav K
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ram Dhan Yadav K
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic