• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock exam question.

 
Rohit Kelkar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the following tag handler defined with <bodycontent>JSP</bodycontent>
public class body extends BodyTagSupport {
public int doAfterBody() throws JspException {
try { pageContext.getOut().print("how are you?"); }catch(IOException e) {}
return SKIP_BODY;
}
}
what will be printed out by the following part of a jsp page?
<prefix:sufix>
<i>Hello</i>
</prefix:sufix>
1) The tag handler won't compile.
2) The jsp page will print Hello how are you?
3) The jsp page will print how are you? Hello
4) The jsp page will print Hello
Correct ans is 4.
If doStartTag is not implemented, how will the ans be 4??
[ November 05, 2002: Message edited by: Jim Yingst ]
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rohit,
See once your jsp documententation, you'll understand that you are implementing doStartTag() by bdefault because it is already defined in javax.servlet.jsp.tagext.BodyTagSupport.
 
Lili yuan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why the answer is 4? If it extends BodyTagSupport, should the "hello" be buffered and finally only "how are you" are printed out?
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe it is returning SKIP_BODY that's why???
 
Rohit Kelkar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clarification.
This question is obviously not from the actual exam but from one of the MOck Exams.
Can someone tell me you to make the subject change?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change the subject by editing your first post - as the poster, you do have that right. But I went ahead and added "Mock" to the title for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic