I have made tld and tag holder (of type Body Tag Support) in which src
is the required attribute.
In JSP:
<%@taglib uri="/WEB-INF/tlds/tld1.tld" prefix="imageViewer1"%>
<!DOCTYPE html>
<html>
<body>
<imageViewer1:NewTagHandler src="dd"></imageViewer1:NewTagHandler>
</body>
</html>
In tag handler I am only printing src
. But I am getting no output.
In tld1.tld:
<tag>
<name>NewTagHandler</name>
<tag-class>taghandler.NewTagHandler</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>src</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
</attribute>
</tag>
In taghandler.NewTagHandler
@Override
public int doAfterBody() throws JspException {
try {
BodyContent bodyCont = getBodyContent();
JspWriter out = bodyCont.getEnclosingWriter();
out.println(src);
writeTagBodyContent(out, bodyCont);
} catch (Exception ex) {
handleBodyContentException(ex);
}
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY;
}
}