1

我是 jsp 新手,我正在尝试在 tomcat 6 上的 jsp 中使用 javabeans 运行测试文件。这是 main.jsp 文件的代码:

<html>
<head>
<title>Using JavaBeans in JSP</title>
</head>
<body>
<center> 
<h2>Using JavaBeans in JSP</h2> 
<jsp:useBean id="test" class="action.TestBean" /> 
<jsp:setProperty name="test" property="message" value="Hello JSP..." /> 
<p>Got message....</p> 
<jsp:getProperty name="test" property="message" /> 
</center> 
</body> 
</html>

这是 javabean TestBean.java 的代码

/* File: TestBean.java */ 
package action; 
public class TestBean
{
private String message = "No message specified";
public String getMessage() {
    return(message);
}
public void setMessage(String message)
{ 
    this.message = message;
}
}

当我尝试在 localhost 上运行 main.jsp 时,出现以下错误:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:161)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:630)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:149)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.ClassNotFoundException: org.apache.jsp.main_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:628)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:149)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
4

0 回答 0