• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Mock Exam Question.  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy CattlePeople !!!

Question from a mock exam:

Consider the tag handler class shown in exhibit.
What will be printed when the above tag is used as follows in a jsp page:

Hello <mylib:mytag> World!</mylib:mytag>




Select 1 correct option.

1. Hello

2. Hello World!

3. Hello In doAfterBody() World!

4. Hello In doAfterBody()

5. None of the above.



I ticked option 4, but the correct answer given was 1.
Anybody can help ?


Regards,
Gaurav.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav,
This one is tricky. I think I am going to be doomed when I take the test.
MyTag extends TagSupport but it does not override the doStartTag() method. The return value for the default implementation of TagSupport.doStartTag() is SKIP_BODY.
Therefore, the body is skipped and the doAfterBody() method is never executed. After doStartTag() returns SKIP_BODY, the thread of execution proceeds directly to doEndTag(). The default implementation of TagSupport.doEndTag() returns EVAL_PAGE.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi gaurav,
i think option 1 is right because
1. if we dont override doStartTag() method, then its default return value is SKIP_BODY.
2. after this doAfterBody() method never executes (since return value for doStartTag() method is SKIP_BODY) and the control passes to doEndTag() method.
3. since we dont override doEndTag() method, its default return value is EVAL_PAGE.
4. so the code prints only Hello

regards,
sudhakar.
 
Gaurav Sahni
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot Ture & sudhakar.
It clears my doubt.



Regards,
Gaurav.

P.S: Less than 24 hrs left for me to take the exam. Keeping finger's crossed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!