MyTag.java
package taglib;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.IOException;
public class MyTag extends TagSupport
{
String text;
public void setText(String s) {
text = s;
}
public int doEndTag() throws JspException {
try {
pageContext.getOut().print(text);
} catch (Exception e) {
throw new JspException(e.toString());
}
return EVAL_PAGE;
}
}
MyTag.tld
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
1.0
1.2
TagExamples
Example tags.
message
taglib.MyTag
text
java.lang.String
web.xml
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
Example web application illustrating the use of tags in the
"request" custom tag library, from the JAKARTA-TAGLIBS project.
http://rntsoft.com/taglibs
/WEB-INF/MyTag.tld
admin
Jsp page with custom tag
<%@ taglib prefix="l" uri="WEB-INF/MyTag.tld" %>
Supporting Attributes in Custom Tags
Supporting Attributes in Custom Tags
The text is: