• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Head First: Chapter 10, Question 10 - doAfterBody question

 
Eoin Brosnan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a query about the following question from Head First Servlet and JSP.

Which about doAfterBody() is true? (Choose all that apply.)

A. doAfterBody() is only called on tags that extend TagSupport.
B. doAfterBody() is only called on tags that extend IterationTagSupport.
C. Assuming no exceptions occur, doAfterBody() is always called after doStartTag() for any tag that implements IterationTag.
D. Assuming no exceptions occur, doAfterBody() is called after doStartTag() for any tag that implements IterationTag and returns SKIP_BODY from doStartTag().
E. Assuming no exceptions occur, doAfterBody() is called after doStartTag() for any tag that implements IterationTag and
returns EVAL_BODY_INCLUDE from doStartTag().


E is the answer that is given but should it not also state that a body has to be provided? From my testing doAfterBody() is not called if the body isn't provided. I don't see it corrected in any errata so I must be missing something.

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading chapter 10 of Murach's Java Servlet and JSP.
Here is an exercise:


Notes :
1. If the body of <mma:product> is not there, it won't display any product information on the browser.
2. From the ProductTag code, you can see if the list only has one product item, the doInitBody is called and displays the item. The doAfterBody is still called, but it returns the SKIP_BODY.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic