刚接触jsp,按照书上的程序试验一下,可出现了好多出错信息!
w_hb 2004-10-28 09:02:45 主要功能是实现一个计数器,将访问者数量保存在count.txt中。
我把count.txt和count.jsp建在同一目录中
源代码如下:
count.jsp
<%@ page contentType="text/html;charset=GB2312"%>
<HTML>
<TITLE>计数器</TITLE>
<BODY>
<center>计数器</center>
<hr>
<%
String path =request.getRealPath("./");
FileReader fr=new FileReader(path+"count.txt");
BufferedReader br=new BufferedReader(fr);
String strNum=br.readLine();
br.close();
fr.close();
%>
<center>您是第<% =strNum% >位访问者。</center>
<%
FileWriter fw =new FileWriter(path+"count.txt");
int Num=Integer.parseInt(strNum)+1;
fw.write(String.valueOf(Num));
fw.close();
%>
</BODY>
</HTML>
运行后提示的信息:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 14 in the jsp file: /jsp/count.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:59: illegal start of expression
=strNum% >浣????????</center>
^
An error occurred at line: 14 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:59: illegal character: \12290
=strNum% >浣????????</center>
^
An error occurred at line: 6 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:51: cannot resolve symbol
symbol : class FileReader
location: class org.apache.jsp.count_jsp
FileReader fr=new FileReader(path+"count.txt");
^
An error occurred at line: 6 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:51: cannot resolve symbol
symbol : class FileReader
location: class org.apache.jsp.count_jsp
FileReader fr=new FileReader(path+"count.txt");
^
An error occurred at line: 6 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:52: cannot resolve symbol
symbol : class BufferedReader
location: class org.apache.jsp.count_jsp
BufferedReader br=new BufferedReader(fr);
^
An error occurred at line: 6 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:52: cannot resolve symbol
symbol : class BufferedReader
location: class org.apache.jsp.count_jsp
BufferedReader br=new BufferedReader(fr);
^
An error occurred at line: 14 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:63: cannot resolve symbol
symbol : variable fw
location: class org.apache.jsp.count_jsp
fw.write(String.valueOf(Num));
^
An error occurred at line: 14 in the jsp file: /jsp/count.jsp
Generated servlet error:
D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java:64: cannot resolve symbol
symbol : variable fw
location: class org.apache.jsp.count_jsp
fw.close();
^
An error occurred at line: 14 in the jsp file: /jsp/count.jsp
Generated servlet error:
Note: D:\Tomcat 4.1\work\Standalone\localhost\_\jsp\count_jsp.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
8 errors