刚接触jsp,按照书上的程序试验一下,可出现了好多出错信息!
主要功能是实现一个计数器,将访问者数量保存在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
我把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
...全文
相关推荐
jsp购物车jsp书上例题
jsp书上例题jsp书上例题jsp书上例题jsp书上例题jsp书上例题
JSP大学使用教程书上的代码
《JSP大学使用教程》 书上代码的电子版,简洁明了
jsp程序设计(第二版)--书上作业和课程设计.zip
jsp程序设计(第二版)--书上作业和课程设计.zip
jsp书上的所有代码
jsp书上的所有代码
word在线编辑,office在线编辑 最完整版本及其PHP/JSP示例程序
内含:在线编辑控件、PHP示例程序、JSP示例程序 本软件基于微软的技术支持文档KB Q311765(市场上现有的好多在线文档编辑控件均基于该文章完成,大家可以很容易的识别),修改了文章所附代码的一些缺陷,添加了一些实际软件开发过程中必需的功能。 本软件为所有新添加功能均为自主开发,拥有全部的知识产权。该软件实现了能够在浏览器窗口中直接编辑MS Office、Kingsoft WPS等复合文档并保存到Web服务器。控件采用标准互联网协议,支持任意后台Web服务器(iis, domino, webaphere, apache等),任意后台操作系统(win2k, win2003, linux, unix等),以及任意后台编程语言(asp, asp.net, jsp, php, vb.net, c#等)和任意web应用服务器体系结构(j2ee, .net等)。


Web 开发
