刚学JSP,有关javabean的问题(50分)

  • 主题发起人 主题发起人 潇翔
  • 开始时间 开始时间

潇翔

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用Tomcat做为运行环境,我不想使用tomcat默认的目录,自己建了一个目录,并已经配好了
虚拟目录。如果我想把javabean也放在这个虚拟目录里请问要做如何设置????????
 
放到WEB-INF/classes目录下面就可以。注意包路径
 
还是没有成功,我说详细点。
tomcat安装目录 d:/tomcat
自己建站的虚拟目录 d:/jsp在此目录中建立了一个 WEB-INF/classes 目录
我把bean放在WEB-INF/classes目录中
但是执行结果出错,情况如下:
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: Unable to compile class for JSP
An error occurred at line: 11 in the jsp file: /numguess.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:/Tomcat/work/Standalone/localhost/jsp/numguess_jsp.java:7: package numdo
es not exist
import num.NumberGuessBean;
^
D:/Tomcat/work/Standalone/localhost/jsp/numguess_jsp.java:44: package numdo
es not exist
num.NumberGuessBean numguess = null;
^

An error occurred at line: 11 in the jsp file: /numguess.jsp
Generated servlet error:
D:/Tomcat/work/Standalone/localhost/jsp/numguess_jsp.java:46: package numdo
es not exist
numguess = (num.NumberGuessBean) pageContext.getAttribute("numguess", PageContext.SESSION_SCOPE);
^

An error occurred at line: 11 in the jsp file: /numguess.jsp
Generated servlet error:
D:/Tomcat/work/Standalone/localhost/jsp/numguess_jsp.java:49: package numdo
es not exist
numguess = (num.NumberGuessBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "num.NumberGuessBean");
^
4 errors

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)

--------------------------------------------------------------------------------
 
用Tomcat管理器就是可建自己的虚拟目录。
步骤如下:
1)http://host:port进入Tomcat管理器
2)点击Tomcat Administration,输入用
户和密码
3)点击Service,右边下拉列表框选择
Create New defaultcontext按要求填写
就可以。
 
你在web-inf/classes下自己建一个文件夹取名叫num应该就可以了吧,根据你jsp的编译错好像是这个问题
 
多人接受答案了。
 
后退
顶部