// create File:java2s.tld in the /WEB-INF/
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
//compile the following code into WEB-INF\classes\com\java2s
package com.java2s;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
public class EmptyTag extends TagSupport
{
public int doStartTag() throws JspException
{
try
{
pageContext.getOut().print("in EmptyTag.doStartTag()");
}
catch (IOException e)
{
System.out.println("Error in EmptyTag.doStartTag()");
e.printStackTrace();
throw new JspException(e); // throw the error to the error page (if set)
} // end of try-catch
return SKIP_BODY;
}
}
// start comcat and load the following jsp page in browser
<%@ taglib uri="/java2s" prefix="java2s" %>
This page uses a custom tag that has neither attributes nor body content.
Here is its output:


No comments:
Post a Comment