初学jsp执行例子时出现如下错误提示,不知为何?请各位帮助,谢谢!
代码如下:
-------------------------------------------------------------------------
<%@ page contentType="text/html;" language="java" import="java.sql.*;" import="java.util.*;" errorPage="" %>
<%!
Hashtable userTable=new Hashtable();
public int getCount(string userName)
{
Integer count=(Integer)userTable.get(userName);
if(count!=null){
int nowCount=count.intValue()+1;
userTable.put(userName,new Integer(nowCount));
return nowCount;
}
userTable.put(userName,new Integer(1));
return 1;
}
%>
<%
String username=request.getParameter("textUserName");
int count=getCount(username);
%>
<html>
<head>
<body>
你好:<font color="#3333ff"><b><%=username%></b></font>
你已经到本站来参观:<font color="#3333ff"><b><%=count%></b></font>次
</body>
</head>
</html>
------------------------------------------------------------------------
错误信息如下:
------------------------------------------------------------------------
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
No 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:420)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:460)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:444)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:294)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
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.5
问题点数:20、回复次数:4Top
1 楼dmhorse(dmhorse)回复于 2003-09-03 19:02:38 得分 0
No JDKTop
2 楼luckybeggar(木子)回复于 2003-09-03 19:06:02 得分 0
安装jdk了吗Top
3 楼SlzAgain(学网络知识,黑日本网站)回复于 2003-09-03 19:21:55 得分 20
没有设置CLASSPATH
-------------1》JDK的安装:
目前最新版的JDK为J2SE1.4,下载页面为http://java.sun.com/j2se/1.4/download.html,选择合适的版本下载。
注意,要下载SDK,而不是JRE。
双击下载的JDK安装文件(文件名为j2sdk-1_4_0-win.exe,可能有所不同),按照默认设置,一路Next/OK,安装完成。
-------------2》JDK的设置:
WinNT平台
右击“我的电脑”=>“高级”=>“环境变量”=>“系统变量”
SET JAVA_HOME=C:\j2sdk1.4.0
SET PATH=%PATH%;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
SET CLASSPATH=%CLASSPATH%;.;%JAVA_HOME%\lib\tools.jar
保存,重新启动。Top
4 楼mabnily(阿甘)回复于 2003-09-03 19:35:37 得分 0
jdk已安装,环境变也已成功设置。执行行其它例子没有问题!Top



