首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

访问量的有关问题

2012-09-08 
访问量的问题Java code%@ page contentTypetext/htmlcharsetgbk%%@ page importjava.sql.*,java

访问量的问题

Java code
<%@ page contentType="text/html;charset=gbk"%><%@ page import="java.sql.*,java.io.*"%><%!    int load(File f){    int temp=0;    try{        temp=new Integer(new BufferedReader(new InputStreamReader(new FileInputStream(f))).readLine());        }catch(Exception e){e.getMessage();}        return temp;    }    public synchronized void save(javax.servlet.http.HttpSession session,int c,File f){        try{                int tem=++c;                session.setAttribute("counter",tem);                PrintStream ps=new PrintStream(new FileOutputStream(f));                ps.println(c);                ps.close();        }catch(Exception e){ e.getMessage();}    }%><%    String fileName=getServletContext().getRealPath("/")+"count"+File.separator+"count.txt";    File f=new File(fileName);    int count=load(f);    if(session.isNew()){        save(session,count,f);    }    %><h4>您是本站的第<%=session.getAttribute("counter")%>位访问者</h4>

以上代码是index.jsp的,把index.jsp和count/count.text上传到jsp服务器上后发现,无论我怎么访问网页count.txt中的数字老是不变,index.jsp中的数字一直不变,可是服务器已开了对count.txt的读写权限,且以上代码在本地测试成功,请问有人知道这是什么原因吗,劳驾了,谢谢

[解决办法]
应该是路径的问题
[解决办法]
input 没有close

热点排行