File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes hfsj 2nd edition chapter 10 , self test question no. 9, page 594 doubt? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "hfsj 2nd edition chapter 10 , self test question no. 9, page 594 doubt?" Watch "hfsj 2nd edition chapter 10 , self test question no. 9, page 594 doubt?" New topic
Author

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

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1


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
Bartender

Joined: Apr 07, 2010
Posts: 1731
    
  25

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

Joined: Apr 04, 2012
Posts: 924
    
    1

thanks alot fritz.....thanks very much
 
wood burning stoves
 
subject: hfsj 2nd edition chapter 10 , self test question no. 9, page 594 doubt?