• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

hfsj 2nd edition chapter 10 , self test question no. 9, page 594 doubt?

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Assume that the tag has been properly configured to allow body content.
Which, if inserted at line 12, would cause the JSP code
<mytags:mytag>BodyContent</mytags:mytag> to output BodyContent?
A. return SKIP_BODY;
B. return EVAL_BODY_INCLUDE;
C. return EVAL_BODY_BUFFERED;
D. return BODY_CONTENT;

the correct answer given is option B i.e. EVAL_BODY_INCLUDE. regarding option C the book says "INVALID BECAUSE IT DIRECTS THE BODY OF THE TAG TO A BUFFER WHICH THIS TAG DOES NOT PROCESS ".

My question is to elaborate as to why option C is invalid

Secondly in the lifecycle(when BodyTagSupport is extended) it is shown in the book that if the doStartTag retursn EVAL_BODY_BUFFERED, the container calls setBodyContent(BodyContent) and then it calls doInitBody(). afterwards it EVALUATES BODY and calls doAfterBody. so that means if EVAL_BODY_BUFFERED is returned the body does get evaluated and it will also print whatever the above question says so OPTION C should also be right. the exact page where this lifecycle is given in the book is at page no. 563

Thanks and Regards
 
Creator of Enthuware JWS+ V6
Posts: 3341
303
Android Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurpeet,

so that means if EVAL_BODY_BUFFERED is returned the body does get evaluated


Correct the body gets evaluated and put into the buffer, but it doesn't mean that it will be in the output.

To see the output you will have to add the following lines in the doAfterBody() method

Have a look at my SCWCD notes, chapter 8.5.3

Regards,
Frits
 
gurpeet singh
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks alot fritz.....thanks very much
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic