This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Chapter 10 Q#9 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Chapter 10 Q#9" Watch "Chapter 10 Q#9" New topic

Chapter 10 Q#9

tehika danait
Ranch Hand

Joined: Oct 13, 2009
Posts: 52
Hi Ranchers
to me the correct answer for Q9 of chapter 10 is C
if I am mistaken and B is correct answer what is the reason?
thanks in advance

SCJP 6(90%), SCWCD 5(92%)
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

tehika it would be better if you post the question here. Not everyone has the book at hand all the time...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
tehika danait
Ranch Hand

Joined: Oct 13, 2009
Posts: 52
The Question say:

Assume that the tag has been properly configured to allow body content.
which, if inserted at line 03, would cause the JSP code

to output BodyContent?
A. return SKIP_BODY;
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

If your doStartTag method returns EVAL_BODY_BUFFERED, then the body content is not written to the client, instead an instance of BodyContent is created and setBodyContent method of your tag class is called. Its then the responsibility of your doEndTag method to actually write the contents of the BodyContent object to the client...
Frits Walraven
Creator of Enthuware JWS+ V6

Joined: Apr 07, 2010
Posts: 1642

Hi Tehika,

Apart from the doEndTag() method you can also write the body to page in the doAfterBody() method.

Look at the following drawing:

If you return EVAL_BODY_INCLUDE you will come directly to the Body Evaluation where the body is "evaluated" which means in this case it is directly output to the page, but if you return EVAL_BODY_BUFFERED the BodyContent object is created and the doInitBody() is called. (like Ankit was saying)
This is the place where you can still do things before the body is "evaluated". You can't output the body yet to the page as it is only available after the "body evaluation" which means in this case that the buffer of the BodyContent is filled with the body. After this you can ouput the body in either the doAfterBody() or the doEndTag() method.

Watch out for trick questions: if you don't override the doStartTag() method in a class that extends the BodyTagSupport class the default implementation is that it will return EVAL_BODY_BUFFERED from the doStartTag() method! Hench the default implementation return types are made bold in this picture.

I hope this helps.

tehika danait
Ranch Hand

Joined: Oct 13, 2009
Posts: 52
Thank you both Ankit and Frits, the idea is now crystal clear.
I agree. Here's the link:
subject: Chapter 10 Q#9
Similar Threads
SCJP Java 6 , Study Guide, Chapter 10:Development, Self-test question 11
JavaCaps Suncertified Java Programmer Mock Test
Question 1 page 362
HFSJ Chapter 10 question doubt
Chapter:1, self test doubt.