JSP+JAVABEAN的记数器的问题!求救高手! 为什么,没人帮我呀,为什么呀 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你这个到底有什么问题? <%@ page contentType="text/html; charset=gb2312"%><%@ page import="java.io.*"%><html><head><title>JSP网页记数器</title></head><body><% BufferedReader test; //BufferedReader对象,读取文件数据 String tmp=null; //文本文件中存储的值 int i=0; //记数值 String path=request.getRealPath(""); //获取URL File f=new File(path,"count.txt"); //获取 File对象 test=new BufferedReader(new FileReader(f)); try{ tmp=test.readLine(); }catch(FileNotFoundException e){ e.printStackTrace(); } if(tmp==null){ //第一次运行时 i=0; } else{ i=(int)(Integer.parseInt(tmp)+1); } //********************* try{ PrintWriter outf=new PrintWriter(new FileOutputStream(f)); outf.println(i); //将i写入文件中 outf.close(); } catch(FileNotFoundException e) { e.printStackTrace(); } test.close();%><p align="center">您是第<%=i%>位访客</p></body></html>我是用了一个File对象的FileReader(File f)FileReader(String s)好像不可以老是提示找不到文件 各位高手,还有其什么方法么为什么会找不到文件呢? 我想在servlet输出一段东西后,停留3秒再转到jsp怎么实现? 新手求教,关于html dom解析获取不到节点的值 如何用webwork标签接收jsp之间传递的参数? 问个servlet的问题 如何检测字符串出现的 如何通过jsp启动一个后台应用程序 用jb做servlet发布到weblogic出错,不知道为什么 请问2个servlet的问题 java怎么实现地图导航 JSP中怎么得到客户端的IP和机器名字? java访问 domino notes数据, 高手指点一下
<%@ page import="java.io.*"%>
<html>
<head>
<title>JSP网页记数器</title>
</head>
<body>
<%
BufferedReader test; //BufferedReader对象,读取文件数据
String tmp=null; //文本文件中存储的值
int i=0; //记数值
String path=request.getRealPath(""); //获取URL
File f=new File(path,"count.txt"); //获取 File对象
test=new BufferedReader(new FileReader(f));
try{
tmp=test.readLine();
}catch(FileNotFoundException e){
e.printStackTrace();
}
if(tmp==null){ //第一次运行时
i=0;
}
else{
i=(int)(Integer.parseInt(tmp)+1);
}
//*********************
try{
PrintWriter outf=new PrintWriter(new FileOutputStream(f));
outf.println(i); //将i写入文件中
outf.close();
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
test.close();
%>
<p align="center">您是第<%=i%>位访客</p>
</body>
</html>我是用了一个File对象的FileReader(File f)
FileReader(String s)好像不可以老是提示找不到文件
为什么会找不到文件呢?