新手请教一个计数器的问题
<%@ 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>
这个程序为什么不好用啊!!????