• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • 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
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2345
90
Android Chrome Eclipse IDE
  • 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
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks alot fritz.....thanks very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic