IntelliJ Java IDE
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
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply 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: 218

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é
Marshal

Joined: Nov 24, 2005
Posts: 14361

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.


[SCBCD Wall of Fame] [My Blog]
All roads lead to JavaRanch
Help Japan. Make a donation.
Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 218

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

Joined: Oct 14, 2010
Posts: 152
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.
Frits Walraven
Rancher

Joined: Apr 07, 2010
Posts: 741

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: 152
What they mean here is that the custom tag (= custom action element) has a body


Thank you Frits...
 
IntelliJ Java IDE
 
subject: Difference between EVAL_BODY_INCLUDE and EVAL_BODY_BUFFERED
 
Threads others viewed
doAfterBody() doubt
tagdependent body-content?
return type of doStartTag()
return type of doStartTag()
doubt in custom tag mock ques 9 HFSJ page:553
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com