自定义标签-众高手帮我看下,这个问题出在哪,该如何解决?急!
最近开始学习“自定义标签”,但在最后运行的时候出现了异常,代码如下:
test.jsp:
<%@ page contentType= "text/html; charset=GBK " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<!DOCTYPE taglib PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<%@ taglib uri= "/WEB-INF/mytag.tld " prefix= "mytag "%>
<html>
<head>
<title> My JSP 'Test.jsp ' starting page </title>
</head>
<body>
This is my JSP page. <br>
Date : <mytag:demo parameter= "date " /> <br>
File : <mytag:demo parameter= "filename " />
</body>
</html>
-------------------------------------------
DemoTag.java:
package jsp;
import java.util.Date;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class DemoTag extends TagSupport {
public int doStartTag() throws
JspException {
try {
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
JspWriter out = pageContext.getOut();
if (parameter.compareToIgnoreCase( "filename ") == 0)
out.print(request.getServletPath());
else
out.print(new Date());
} catch (
java.io.IOException e) {
throw new JspTagException(e.getMessage());
}
return SKIP_BODY;
}
private String parameter = "date ";
public void setParameter(String parameter) {
this.parameter = parameter;
}
public String getParameter() {
return parameter;
}
}
-----------------------------------------
web.xml:
<?xml version= "1.0 " encoding= "UTF-8 "?>
<web-app xmlns= "http://java.sun.com/xml/ns/j2ee " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " version= "2.