• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can somebody give me an example

 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
can somebody explain this using an example,
"By default, any content written to the output stream is immediately sent to the client. Buffering allows content to be written before anything is actually sent back to the client, thus providing the servlet with more time to set appropriate status codes and headers or forward to another Web resource."
i read this here
regards,
maulin.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"By default, any content written to the output stream is immediately sent to the client.
As much as this stmt is true in itself, this behavior is goverened by the implementation of the App. Server.
Buffering allows content to be written before anything is actually sent back to the client, thus providing the servlet with more time to set appropriate status codes and headers or forward to another Web resource."
The use of the isCommitted() method will help you in deciding if the response is committed (sent to the client) or not. When the buffer size is zero (you need to set the buffer="none" in a JSP) if the page has enough content, it is committed to the client immediately since there is not place to store it. On the other hand, if a buffer is available (which is the default for most servers), the the content is stored in this buffer and is NOT committed to the client till the buffer is full.
I will post the code in a second post......It is pretty big piece of code. Also I am giving you an example with JSP, which is no different thatn a servlet just that you don't have to compile and re-compile.
- satya
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try plaing with the page directive and the content......and observe the output in the Tomcat console........
Good luck.

- satya
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice example!
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi satya,
got it! btw, i guess if we say buffer="0kb" in page directive it is same as having no buffering and saying buffer="none". isn't it?
i also read Ken's notes regarding this sendError() and sendRedirect() etc which mentions about buffering theory and how it helps...
thanks
maulin.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello.... ..........Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............


Hi
Mark
p.s. I like the example
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will be amazed how many problems "Cut and Paste technology" can solve......
- satya
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good example.
a question:
Are there other reasons to use buffer, but faster/more responsive pages?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there other reasons to use buffer, but faster/more responsive pages?

Not that I know of......
- satya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic