(散分)关于在Tomcat5.0.18中使用Bean和Servlet的问题,请教高手!

peterdoo 2004-02-22 11:35:15
初学JSP,出于测试的目的,我用的基本配置如下:WINXP + J2SDK1.4.1_01 + TOMCAT5.0.18.环境变量设置大概正确(类路径可能有所缺失).JSP页面执行正常,表单提交正常,在TOMCAT5.0中好象已经不存在中文乱码问题了.当然,我还没有试过数据库!但是,JAVABEANS,SERVLETS都不能正常执行,用BEAN时,报错如下:
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

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

exception

org.apache.jasper.JasperException: Car
org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:122)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1051)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1079)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Generator.generate(Generator.java:3253)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.ClassNotFoundException: Car
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1383)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1230)
org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:120)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1051)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1079)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Generator.generate(Generator.java:3253)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.18

另外,我的Bean代码如下:
public class Car{
private String Make;
public Car(){
Make="Ford";
}
public void setMake(String make){
this.Make=make;
}
public String getMake(){
return this.Make;
}
}
保存在WEB-INF\classes目录下,名为Car.java.并且编译生成Car.class文件.
JSP文件如下:
<center>
This is the first page of JavaBean!
<br>
<jsp:useBean id="myCar" scope="request" class="Car" />
<jsp:setProperty name="myCar" property="Make" value="Ferria" />
The car is made by : <jsp:getProperty name="myCar" property="Make" />
</center>
问题可能出在WEB.XML文件里的设置上,但我不知道如何设置,和设置哪个目录下的WEB.XML文件,请高手指点.谢了!
...全文
5 点赞 收藏 13
写回复
13 条回复
切换为时间正序
请发表友善的回复…
发表回复

还没有回复,快来抢沙发~

发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告