• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3411
320
Android Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks alot fritz.....thanks very much
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic