奇怪的jsp计数器的绝对路径和相对路径问题
hiei 2005-08-04 01:26:50 //我的计数器文件如下:counter.jsp
<%@ page language="java" contentType="text/html;charset=gb2312" >
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
<TITLE> 计数器演示程序 </TITLE>
</head>
<body>
<!--创建并调用bean(Counter)-->
<jsp:useBean id="Counter" scope="request" class="Counter" />
<%
//调用counter对象的ReadFile方法来读取文件count.txt中的计数
String cont=Counter.ReadFile("//count.txt");
//调用counter对象的ReadFile方法来将计数器加一后写入到文件count.txt中
Counter.WriteFile("count.txt",cont);//问题的错误之处!
%>
<center>
您是第<font color="red"><%=cont%></font>位访问者
</center>
</body>
</html>
如果我将Counter.WriteFile("count.txt",cont)换成绝对路径Counter.WriteFile("d://counter//count.txt",cont)没有问题,相对路径("count.txt",cont)为什么有问题呢??
请教各味大虾!