帮忙看一下代码!!!!急!!!!!!!!!!

dike103 2003-08-03 10:58:56
<%@ page contentTpye="text/html;charset=gb2312" %>
<%@ page import="java.io.*" %>
<html>
<head>
<title>计数器</title>
</head>
<body>
<%
BufferedReader file1;
String filepath1="/100.txt";
file1=BufferedReader(new FileReader(filepath1));
String readstr1=null;
int writestr1=1;
try
{
//读取一行数据并保存到readstr变量中
readstr1 = file1.readLine();
}
catch (IOException e)
{//错误处理
System.out.println("读取数据错误.");
}
if(readstr1==null)readstr1="没有任何记录";
else
{
writestr1=Integer.parseInt(readstr1)+1;
}
PrintWriter pw;
pw=new PrintWriter(new FileOutputStream(filepath1));
pw.println(writestr1);
pw.close();
%>
<center>
<table>
<tr>
<td>你是第:</td>
<td><%=readstr1%></td>
<td>访问者</td>
</tr>
</table>
</body>
</html>


产生的是执行错误
请问我错在哪里呢?
还有就是我的100.txt文件要放在哪里???///
我的环境是:apache+tomcat
路径分别是:C:\Apache Group\Apache2
C:\Apache Group\Tomcat 4.0
...全文
85 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dike103 2003-08-03
  • 打赏
  • 举报
回复
我试了都不可以啊!
snake_eye 2003-08-03
  • 打赏
  • 举报
回复
我也遇到相对路径的问题!
Jeff 2003-08-03
  • 打赏
  • 举报
回复
好像我以前碰见过类似的问题,那个txt在Tomcat/bin这个目录下
hjhd0 2003-08-03
  • 打赏
  • 举报
回复
你的100.txt也可放在一个绝对路径下啊 如 d:\100.txt 试试看了

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧