HF Page 766 Ques 12 Final Mock Exam
Ques12
Given this tag handler
package com;
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import java.io.*;
public class WorthLessTag extends TagSupport {
private
String x;
public void setX(String x) { this.x = x; }
public int doStartTag() throws JspException {
try {
pageContext.getOut().print(x);
}
catch (IOException e) {}
if("x".equals(x))
return SKIP_BODY;
else
return EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspException {
try {
pageContext.getOut().print("E");
}
catch (IOException e) {}
if("y".equals(x))
return SKIP_PAGE;
else
return EVAL_PAGE;
}
}
and given this TLD
<tag>
<name>worthless</name>
<tag-class>com.WorthLessTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>x</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
The tld clearly mentions that body-content should be empty but the doStartTag returns EVAL_BODY_INCLUDE.
Why doesn't this give an error ?