这要看是什么版本。tomcat5.0以上的和tomcat5。0以下的不一样。 我最近装了一个tomcat5.0.7的版本。按照书上提示将javabean放在WEB-INF\classes下。可程序提示服务器内部错误。建议我将JDK里面lib里的tools.jar文件放在tomcat目录下的common目下写的lib中。我照办了。可还是提示同样的信息。后来。我就运行tomcat4.0。我将javabean文件放在tomcat4.0目录下的classes文件夹中。然后。在jsp文件中将该javabeans导入。 <%@ page import="test"%> <jsp:useBean id="oneTest" scope="session" class="test" /> 运行就ok了 以上是在tomcat4.0下运行成功的。在tomcat5.0.7下出现错误提示为: 大家帮我看看。是为什么? --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPNo Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. If using an alternate Java compiler, please check its installation and access path. org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:307) org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415) org.apache.jasper.compiler.Compiler.compile(Compiler.java:455) org.apache.jasper.compiler.Compiler.compile(Compiler.java:439) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) note The full stack trace of the root cause is available in the Tomcat logs.
package xxx; //xxx是你自己定义的包名,随便起名就可以了
然后编译,编译完了把class放到tomcat虚拟目录下的classes\xxx目录下,xxx目录要自己建,这个目录名和你的包名(package里指定的)要一致,大小写也要一致
最后修改你的jsp页面:
<jsp:useBean id = "随便写"
scope= "session"
class= "xxx.类名"/>
在页面里调用bean就用id里定义的名字来调用就行了
例如:Tomcat_Home\shared\classes\Service1\test.class(test.java)
在页面中如此调用该Bean:
<jsp:useBean id="oneTest" scope="session" class="Service1.test" />
我被这个问题折磨2天了,TMD!
然后在爱你的BEAN代码里加上
PACKAGE ***;
我最近装了一个tomcat5.0.7的版本。按照书上提示将javabean放在WEB-INF\classes下。可程序提示服务器内部错误。建议我将JDK里面lib里的tools.jar文件放在tomcat目录下的common目下写的lib中。我照办了。可还是提示同样的信息。后来。我就运行tomcat4.0。我将javabean文件放在tomcat4.0目录下的classes文件夹中。然后。在jsp文件中将该javabeans导入。
<%@ page import="test"%>
<jsp:useBean id="oneTest" scope="session" class="test" />
运行就ok了
以上是在tomcat4.0下运行成功的。在tomcat5.0.7下出现错误提示为:
大家帮我看看。是为什么?
--------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPNo Java compiler was found to compile the generated source for the JSP.
This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
If using an alternate Java compiler, please check its installation and access path. org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:307)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:455)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
放到
c:\tomcat\webapps\ROOT\WEN-INF\classes\你的包\你的BEAN文件
下就可以