• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is clearing or flushing buffer same as committing of response

 
Maya Dolas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am confused with the terminologies

"flushing of buffer" and "committing the response".

Are they same, if not could some one throw more light what happens in each case.

I was confused due to the jsp include and forward actions. Now in the include action if the flush attribute is set to true, the buffer is flushed prior to the inclusion. Now what does this flushing exactly mean - does it mean mere clearing of the buffer or sending the buffered contents to client (in other words start the committing of response). If its not committing of response, consider the foll ex



Now the contents of other.jsp


Now in this case will the contents of the including file before the include action sent to the client or they would be just ignored? If they are ignored it would result in a wrong HTML structure.

Now in jsp forward action, the buffered contents of the forwarding component are always ignored/cleared before the request processing is delegated to the forwarded component. Now in this case if buffer clearing is committing of response, then we should get IllegalStateException everytime, isn't it?

Also one more doubt, does the buffer and autoFlush attributes of page directive play some role in above cases.

Thanks
[ April 10, 2008: Message edited by: Bear Bibeault ]
 
swapna rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
flushing the buffer is same as committing the response where as clearing the buffer means the buffer content will be ignored.
-
-
-
-
<jsp:include page="other.jsp" flush="true">
-
-
Here the flush attribute determines the order in which the output should be displayed.In this example, what ever output is written by you before <jsp:include > action is shown to the end user as this action is a include action.
If you use <jsp:forward> in place of <jsp:include> the content prior to the standard action is ignored and the forwarded page output will be shown.But before using the forward action if you explicitly flush the buffer by using flush() you will get an IllegalStatusException.
Hope this clears your doubt.
 
Maya Dolas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Still have one doubt. As you have mentioned in case of forward action, in case I do an explicit flush before invoking the forward action, IllegalStateException would be thrown. Now consider a case

In JSP I have set the buffer size as 16kb and autoFlush attribute to true. Now if before the forward action is invoked the contents exceed 16kb and since the autoFlush attribute is true the contents would be flushed (committed). Now will IllegalStateException would be thrown when the forward action is invoked?

Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSP I have set the buffer size as 16kb and autoFlush attribute to true. Now if before the forward action is invoked the contents exceed 16kb


The contents written may exceed 16kb but the servlet container will have automatically written the response headers and the buffer full of characters when the buffer size was reached. Thats the whole idea.

If you want to avoid committing the response, set a higher buffer size.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!