Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock exam question

 
Mark heningen
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I was attempting one mock exam from
http://www.javabeat.net/cert/scwcd-5-0/mock-exams/scwcd_mock_exam_questions_3.php
1. Regarding the processing of a BodyTag handler, in which of the following cases a BodyContent object will be "pushed" into the pageContext?
Select 1 correct option.
A.If the doStartTag() returns EVAL_BODY_INCLUDE
B.If the doStartTag() returns EVAL_BODY_BUFFERED
C.If the doStartTag() returns SKIP_BODY
D.If the doStartTag() DOES NOT return SKIP_BODY
E.A BodyContent object it is always created and pushed no matter what doStartTag() returns
correct answer is C
i think that it should be B.
any views?
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you SKIP_BODY you won't process the BodyContent. And the question says "object will be pushed into the pageContext", in other words, "the object will be processed (or evaluated)".
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2343
90
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark, Hebert,

in which of the following cases a BodyContent object will be "pushed" into the pageContext?

I find this question rather vague. First of all a BodyContent object is only created when the doStartTag() method returns EVAL_BODY_BUFFERED.

The next thing is that, when you read the API of the PageContext:
public BodyContent pushBody()
Return a new BodyContent object, save the current "out" JspWriter, and update the value of the "out" attribute in the page scope attribute namespace of the PageContext.
public JspWriter popBody()
Return the previous JspWriter "out" saved by the matching pushBody(), and update the value of the "out" attribute in the page scope attribute namespace of the JspContext.

So I would say: the BodyContent is pushed from the PageContext (by calling pushBody()) and handed over to your TagHandler code, and never into.

My first reaction would be answer B, but questions remain about the question itself....

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic