我是JSP新手。我試圖在TOMCAT服務器上運行JSP頁面。在Tomcat服務器中運行JSP頁面?
以下是我使用的步驟。
1)。創建了以下JSP頁面以消除當前日期。
<%@page contentType="text/html" import="java.util.*" %>
<html>
<body>
<p> </p>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing
="0" width="460" bgcolor="#EEFFCA">
<tr>
<td width="100%"><font size="6" color
="#008000"> Date Example</font></td>
</tr>
<tr>
<td width="100%"><b> Current Date
and time is: <font color="#FF0000">
<%= new java.util.Date() %>
</font></b></td>
</tr>
</table>
</center>
</div>
</body>
</html>
2)與我還創建JSPSample folder.Inside WEB_INF內部WEB-INF文件夾在Tomcat
3)的名稱在Date.jsp web應用(web應用/ JSPSample/date.jsp)保存它夾我放置的web.xml用下面的代碼
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>
<display-name>JSP test client</display-name>
<servlet>
<servlet-name>JSP Sample</servlet-name>
<display-name>JSP Sample</display-name>
<description>no description</description>
<jsp-file>/date.jsp</jsp-file>
</servlet>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
4)的文件夾結構看起來像
webapps
--JSPSample
----WEB-INF--web.xml
----date.jsp
5)之後,打開任何互聯網瀏覽器,鍵入以下URL,而試圖在刷新頁面波紋管誤差也呈現出
運行JSP文件org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67)
root cause
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:620)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.UIDesign_jsp
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:618)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.hp.sips.basic.container.impl.servlet.RestFilter.doFilter(RestFilter.java:67)
http://localhost:8080/JSPSample/date.jsp
以下錯誤顯示
你不需要在web.xml中定義jsp文件 –
是的,我刪除了那個..但不工作 – chinchu