请帮看一下这个jsp那儿出错,在线等待.
SimpleCount.jsp
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Simple Counter</title>
</head>
<body gbcolor=#ffffff>
<%@ page import="java.io.*"%>
<%
BufferedReader file;
String countFile = "count.txt";
try
{
file = new BufferedReader(new FileReader(countFile));
}
catch(IOException e)
{
out.println(e.getMessage());
}
String readstr=null;
int writestr=1;
try
{
readstr = file.readLine();
}
catch(IOException e)
{
System.out.println("读取数据错误.");
}
if (readstr == null) readstr ="没有任何记录";
else
{
writestr = Integer.parseInt(readstr) + 1;
}
try
{
PrintWriter pw;
pw = new PrintWriter(new FileOutputStream(countFile));
pw.println(writestr);
pw.close();
}
catch (IOException e)
{
out.println(e.getMessage());
}
%>
<p align="center">
--><h1>文字模式访问计数器: </h1>
<h3>你是本网页的第
<font color="FF0000" size="7">
<%=readstr%>
</font>名访客
</h3>
</p>
</body>
</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
An error occurred at line: 10 in the jsp file: /SimpleCount.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\software\Tomcat 5.0\webapps\test\work\org\apache\jsp\SimpleCount_jsp.java:58: variable file might not have been initialized
readstr = file.readLine();
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
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.16