aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EVAL_BODY_BUFFERED again? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EVAL_BODY_BUFFERED again?" Watch "EVAL_BODY_BUFFERED again?" New topic
Author

EVAL_BODY_BUFFERED again?

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I did a search on EVAL_BODY_BUFFERED and didn't find a good answer as to what this actually does.
Taking the word Buffered, I would assume that it would hold what was in the body into a "Buffer" and not release it until the buffer was filled, or was told to flush.
But how does that relate to a Body of a tag?
In the API it shows this. But it hasn't clicked in my brain.
If EVAL_BODY_BUFFERED is returned, then a BodyContent object will be created (by code generated by the JSP compiler) to capture the body evaluation. The code generated by the JSP compiler obtains the BodyContent object by calling the pushBody method of the current pageContext, which additionally has the effect of saving the previous out value. The page compiler returns this object by calling the popBody method of the PageContext class; the call also restores the value of out.

Thanks
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Any help? Please.
Mark
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
I was waiting for someone who has better knowledge to take a bite....but anyways...
When this is returned, I am assuming that a
BufferedOutput object is created and placed on the pageContext. For the output generated from evaluation of the rest of the Body is first added to this BufferedOutput (which is differect from the implicit out object).
Thus you are NOT continously writing to the out obj, but you write to it (from this BufferedOutput obj) after the complete evaluation of the Body.
Makes sense.....anyother thoughts please ?
regds.
- satya


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I think that a beautiful answer. Makes more sense to me now.
Thanks
Mark
salman 2020
Greenhorn

Joined: Feb 13, 2002
Posts: 5
IF you would follow these steps the whole thing will become clear.Here is how it goes about.
1.in the doStartTag the the implicit out object of pageContext is used for writing the response to client.obtained by using pageContext.getOut()
2. Now if the doStartTag method returns EVAL_BODY_BUFFERED then a new bufferedobject is created by filling that object with the contents of the body in between the tags.As you must me aware of a stack(LIFO STRUCTURE) this buffered object is stored in the stack when the pageContext.pushBody() is executed(all this stuff is done all by itself internally so don't worry about it)
now if try to acess the out object using pageContext.getOut() what we get is the BodyContent object and not the one to write to the client.
Now when we enter the doEndTag() the pageContext.popBody() is executed removing the bodyContent objectt.In this we now have our implicit out object again for writing back to the client.Simple as this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EVAL_BODY_BUFFERED again?