• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt Enthuware Mock Exam

 
gopal venu
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given:

<%@ taglib uri="example" prefix="example" %>
<example:aTagWithBody>
<%="Body Content"%>
</example:aTagWithBody>
If the aTagWithBody handler extends from TagSupport and returns EVAL_BODY_BUFFERED from doStartTag(), what will the above page print?




Select 1 correct option.
a The tag handler class would not compile.
It will, because the compiler only checks whether the doStartTag() is returning an int or not. It does not check whether the int value is valid or not.

b An exception at request time.


c "Body Content" will NOT be printied.


d "Body Content" will be printied.


e None of these.


General Comments
At request time, the container validates the return value of the doStartTag() methods. In this case, since the Tag handler extends from TagSupport, it does not implement BodyTag interface and so it cannot return BodyTag.EVAL_BODY_BUFFERED from the doStartTag() method. This will cause a ServletException to be thrown from the JSP page.

When I tried on tomcat server its nicely printing the body content.So I think D is the correct Answer
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not have that exam. However, I produced the same results, as indicated in the "Extending BodyTagSupport (HFS CH10 Q9)" post.

Although the answers for the question suggest it is not be relevant, did the original question include information on the <body-content> element?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic