testtag.java

来自「J2EE关于JSP,SERVERLET的多个实用例子」· Java 代码 · 共 33 行

JAVA
33
字号
//Code for the tag handler:TestTag.java
import java.io.IOException;
import java.util.Date;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

//Implementing the tag generates the HTML
public class TestTag extends TagSupport
{

	//This is the start of the tag
	public int doStartTag() throws JspTagException
	{
		return EVAL_BODY_INCLUDE;
	}
	//This is the end of the tag
	public int doEndTag() throws JspTagException
	{
		String dateString=new Date().toString();
		try
		{
				pageContext.getOut().write("Hello everybody</br>");
				pageContext.getOut().write("Date: " + dateString + "<p/>");
		}
		catch(IOException ee)
		{
			throw new JspTagException("Error encountered");
		}
		//This return value evaluates the rest of the page
		return EVAL_PAGE;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?