This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED" Watch "Difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED" New topic
Author

Difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED

Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 219

Hi ranchers,

What is the difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED?
From my opinion, EVAL_BODY_INCLUDE is for body-content=empty or tagdependent and EVAL_BODY_BUFFERED is for body-content=JSP. Am I correct?


Hendy Setyo Mulyo
SCJP 1.4 (95%), SCWCD 1.4 (94%)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

With EVAL_BODY_INCLUDE, you have no chance to work with the body, as it is simply being written to the client.
With EVAL_BODY_BUFFERED, the body is stored in a buffer, which you can decide to output or not, and even change its content.
(imagine a "upper" tag which would change the body's content in uppercase)

Note that if you are using BodyTagSupport, the default return value for doStartTag is EVAL_BODY_BUFFERED.

Details from the spec:
If EVAL_BODY_INCLUDE is returned, and the custom action element is not empty, setBodyContent() is not invoked, doInitBody() is not invoked, the body is evaluated and �passed through� to the current out, doAfterBody() is invoked and then, after zero or more iterations, doEndTag() is invoked. If the custom action element is empty, only doStart() and doEndTag() are invoked.

If EVAL_BODY_BUFFERED is returned, and the custom action element is not empty, setBodyContent() is invoked, doInitBody() is invoked, the body is evaluated, doAfterBody() is invoked, and then, after zero or more iterations, doEndTag() is invoked. If the custom action element is empty, only doStart() and doEndTag() are invoked.


[My Blog]
All roads lead to JavaRanch
Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 219

Thanks for the explanation, Satou.
I understand now
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
I am need of differences between EVAL_BODY_INCLUDE AND EVAL_BODY_BUFFERED. While exploring java ranch i found this thread. After reading this thread i got a doubt...

If EVAL_BODY_INCLUDE is returned, and the custom action element is not empty


What is custom action element?


Thanks & Regards,
Vipul Kumar.


Thanks
Vipul Kumar
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1623
    
  23

Hi Vipul Bondugula,

What is custom action element?

What they mean here is that the custom tag (= custom action element) has a body, so like:


Regards,
Frits
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
What they mean here is that the custom tag (= custom action element) has a body


Thank you Frits...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED
 
Similar Threads
tagdependent body-content?
doubt in custom tag mock ques 9 HFSJ page:553
doAfterBody() doubt
return type of doStartTag()
return type of doStartTag()