aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Can somebody give me an example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Can somebody give me an example" Watch "Can somebody give me an example" New topic
Author

Can somebody give me an example

Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
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

Joined: Jun 03, 2000
Posts: 5040
"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


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Try plaing with the page directive and the content......and observe the output in the Tomcat console........
Good luck.

- satya
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Nice example!
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
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

Joined: Feb 05, 2001
Posts: 17256
    
    6

Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............Hello.... ..........Hello..............Hello..............Hello..............Hello..............Hello..............Hello..............


Hi
Mark
p.s. I like the example


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

Joined: Jun 03, 2000
Posts: 5040
You will be amazed how many problems "Cut and Paste technology" can solve......
- satya
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
good example.
a question:
Are there other reasons to use buffer, but faster/more responsive pages?
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Are there other reasons to use buffer, but faster/more responsive pages?

Not that I know of......
- satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can somebody give me an example