文章探索:   分类:    关键字:  
  + 栏目导航
  + 相关文章
JSP随机数/Javascript随机数
利用XMLHTTP无刷新获取数据
JSP白皮书
在jsp中发送email
为什么jsp不能取代servlet?
jsp的5个不足之处
JSP技巧:发送动态图像
用JSP操作Cookie
简易成绩查询系统
用JSP创建WAP应用
在Windows/NT上建立JSP环境
用jsp连接数据库大全
如何成为一个优秀的JSP程序员
ASP与JSP的比较
处理表单数据
JSP及语法概要
处理Cookie
jsp文件操作之写入篇
一个可以防止刷新的JSP计数器
jsp计数器代码
JSP简明教程
在Java中使用Oracle blob
JSP入门初级教程之预定义变量的使用
在JSP中使用JavaMail(2)
在JSP中使用JavaMail
JSP/Servlet的重定向技术综述
JSP 语法详解(2)
JSP 语法详解(1)
数据库的连接与关闭


技术教程 -> JSP教程 ->  
jsp计数器代码
来源:转载   人气:1760   录入时间:2007-11-8
    
   <!--
   JSP-Hitcounter counts sessions.
   Copyright (C) 2000 Jesper Schmitz Mouridsen.
   Visit www.webappcabaret/jsm2/webapps.jsp?find=jsphcs for more info.
   
   This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.opensource.org/licenses/gpl-license.html for more details
   -->
   
   
   <%
   
   BufferedReader inf = new BufferedReader(new FileReader("/path/to/counter.txt"));
   int tmp = Integer.parseInt(inf.readLine());
   int i=0;
   
   try {
   
   i = Integer.parseInt(request.getSession().getValue("tal").toString());
   } catch (NullPointerException t) {i=0; }
   
   if (i==0) {
   tmp++;
   
   PrintWriter outf = new PrintWriter(new BufferedWriter(new FileWriter("/path/to/counter.txt")));
   outf.println(tmp);
   outf.close();
   inf.close();
   request.getSession().putValue("tal", "1");
   }
   
   BufferedReader inf2 = new BufferedReader(new FileReader("/path/to/counter.txt"));
   %>
   <%
   String zeroes="";
   String hits = inf2.readLine();
   inf2.close();
   for (int t=0; t < 8-hits.length(); t++) {
   zeroes=zeroes+"0"; }
   out.println(zeroes + hits);
   %>
   
   




Copyright(C)2007-2024 广州市佳沛数码科技有限公司 版权所有
公司地址: 广州市荔湾区东漖北路560号511室
电话:020-81803473 传真:020-81544987