關於開發jsp標籤的環境配置問題
有四個檔案,一個jsp,一個xml,一個tld,一個java文,這幾個檔案搭建一個WEB應用(在tomcat下).
1,jsp:
<%@ taglib uri="date" prefix="MyDate"%>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
</head>
<body>
<MyDate:displayDate/>
</body>
</html>
2,java
package lesson.taglib;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class DisplayDate extends TagSupport{
public int doStartTag() throws JspException{
JspWriter out = pageContext.getOut();
try{
out.println(new Date());
}catch(Exception e){
e.printStackTrace();
}
return SKIP_BODY;
}
}
3,xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<taglib>
<taglib-uri>date</taglib-uri>
<taglib-location>/WEB-INF/date.tld</taglib-location>
</taglib>
</web-app>
4,tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.2</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>date</short-name>
<description>
This is a show date taglib example.
</description>
<tag>
<name>displayDate</name>
<tag-class>lesson.taglib.DisplayDate</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
問題在於,在tomcat下執行會報錯,而且全班幾十個人,有的機子執行正常,有的機子執行不正常.重灌tomcat無濟於是.有的機子重灌了作業系統,就正常了.
不正常的原因(tomcat顯示的錯誤提示如下.):
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:435)
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:24
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:162)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
1,jsp:
<%@ taglib uri="date" prefix="MyDate"%>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
</head>
<body>
<MyDate:displayDate/>
</body>
</html>
2,java
package lesson.taglib;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class DisplayDate extends TagSupport{
public int doStartTag() throws JspException{
JspWriter out = pageContext.getOut();
try{
out.println(new Date());
}catch(Exception e){
e.printStackTrace();
}
return SKIP_BODY;
}
}
3,xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<taglib>
<taglib-uri>date</taglib-uri>
<taglib-location>/WEB-INF/date.tld</taglib-location>
</taglib>
</web-app>
4,tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.2</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>date</short-name>
<description>
This is a show date taglib example.
</description>
<tag>
<name>displayDate</name>
<tag-class>lesson.taglib.DisplayDate</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
問題在於,在tomcat下執行會報錯,而且全班幾十個人,有的機子執行正常,有的機子執行不正常.重灌tomcat無濟於是.有的機子重灌了作業系統,就正常了.
不正常的原因(tomcat顯示的錯誤提示如下.):
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagInfo.<init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljavax/servlet/jsp/tagext/TagLibraryInfo;Ljavax/servlet/jsp/tagext/TagExtraInfo;[Ljavax/servlet/jsp/tagext/TagAttributeInfo;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljavax/servlet/jsp/tagext/TagVariableInfo;Z)V
org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:435)
org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:24
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:162)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
相關文章
- 關於 a 標籤跳轉問題
- JSP簡單標籤標籤庫開發JS
- jsp標籤相關問題;推薦大家一個霸氣的標籤fnJS
- 關於標籤庫的問題,請求援助
- 關於jsp中轉發的問題JS
- 關於:laravel開發環境Laravel開發環境
- JSP中巢狀struts標籤的問題JS巢狀
- FusionChartsFree的JSP標籤開發薦JS
- 關於QGis1.8二次開發的環境配置
- golang 開發環境問題Golang開發環境
- 關於環境變數設定的問題變數
- Java初學者:Jsp開發環境配置全過程JavaJS開發環境
- 開發環境配置開發環境
- Maven-關於在環境變數中配置兩個maven的問題Maven變數
- emacs開發環境配置(4)——rust開發環境Mac開發環境Rust
- 關於幾個MySQL環境問題的對比MySql
- 一個很奇怪的問題:關於struts自定義標籤
- 關於html的a標籤的target="__blank "的安全漏洞問題HTML
- 配置開發環境、生成環境、測試環境開發環境
- 關於vue-cli開發環境中跨域的處理-配置代理Vue開發環境跨域
- react 配置開發環境React開發環境
- js開發環境配置JS開發環境
- Java開發環境配置Java開發環境
- weex開發環境配置開發環境
- Arduino開發環境配置UI開發環境
- Ubuntu開發環境配置Ubuntu開發環境
- [求助]jsp+javaBean除錯環境問題!JSJavaBean除錯
- 關於w10配置java jdk以及jre環境變數問題JavaJDK變數
- OpenShift 本地開發環境配置(基於 Minishift)開發環境
- 關於jsp建網站的問題JS網站
- win10安裝開發配置環境的標準流程Win10
- 我的Ubuntu 開發環境配置Ubuntu開發環境
- 配置豪華的 Windows 開發環境Windows開發環境
- **開發環境一些基本問題開發環境
- mac 配置mysql環境 Navicat 問題MacMySql
- Flutter配置環境常見問題Flutter
- 關於 dnmp 環境下,laravel 試用 swoole 遇到的問題Laravel
- Unix環境中配置JSP的方法(轉)JS