Folks, help me here:
What is the result of accessing the following
JSP document? (Choose one.)
JSP document:
<html xmlns:mytags="http://www.osborne.com/taglibs/mytags"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core" >
<jsp
utput omit-xml-declaration="true" />
<jsp
irective.page contentType="text/html" />
<jsp
irective.page import="java.io.Writer" />
<body>
<jsp:scriptlet>Writer myOut = pageContext.getOut();</jsp:scriptlet>
<mytags:question18>
<jsp:scriptlet>myOut.write("Body");</jsp:scriptlet>
</mytags:question18>
</body>
</html>
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.*;
public class Question18 extends BodyTagSupport {
public int doAfterBody() throws JspException {
try {
bodyContent.write("Legs");
bodyContent.writeOut(bodyContent.getEnclosingWriter());
} catch (IOException e) {
throw new JspException(e);
}
return Tag.EVAL_PAGE;
}
public void doInitBody() throws JspException {
try {
bodyContent.write("Head");
} catch (IOException e) {
throw new JspException(e);
}
}
}
A.Translation error (source generation)
B.Translation error (source compilation)
C.Run-time error
D.Output of HeadBodyLegs
E.Output of BodyHeadLegs
F. Output of BodyHeadBodyLegs
According to the mock�s engine the answer is : "E".
My question is..how is it possible..if we dind't declare a overrided doStartTag method in "Question18" class.
For me, "doAfterBody" is not supposed to be processed, since it�s a Classic tag, and the default value for doStartTag is "SKIP_BODY".
Therefore, neither the "body" would be processed nor "doAfterBody" and "doInitBody" would be executed too.
What dind't i figure out here? ???
Ah, and another thing...(doAfterBody shouldn�t be returning "EVAL_PAGE" since it�s "doEndTag�s method".
Would it be a runtime exception right?
Tks.