标题:新手请教一个计数器的问题
只看楼主
yifeng701
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-7-4
 问题点数:0 回复次数:0 
新手请教一个计数器的问题
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.io.*" %>
<HTML>
<body bgcolor=green><front=3>
<%! int number=0;
synchronized void countPeople()
{
if(number==0)
{
try{File f=new File("D:/tomcat","countPeople.txt");
FileInputStream in=new FileInputStream(f);
DataInputStream dataIn=new DataInputStream(in);
number=dataIn.readInt();
number++;
in.close();dataIn.close();
}
catch(FileNotFoundException e)
{ number++;
try {File f=new File("D:/tomcat","countPeople.txt");
FileOutputStream out=new FileOutputStream(f);
DataOutputStream dataOut=new DataOutputStream(out);
dataOut.writeInt(number);
out.close();dataOut.close();
}
catch(IOException ee){}
}
catch(IOException ee)
{
}
}
else
{number++;
try{File f=new File("D:/tomcat","countPeople.txt");
FileOutputStream out=new FileOutputStream(f);
DataOutputStream dataOut=new DataOutputStream(out);
dataOut.writeInt(number);
out.close();dataOut.close();
}
catch(FileNotFoundException e){}
catch(IOException e){}
}

}
%>
<%
if(session.isNew())
{countPeople();
String str=String.valueOf(number);
session.setAttribute("count",str);
}
%>
<P>您是第<%=(String)session.getAttribute("count")%>个访问本站的人。
<BODY>
<HTML>
这个程序为什么不好用啊!!????
搜索更多相关主题的帖子: 计数器 html number import 
2006-03-26 12:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-52892-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.023435 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved