您的位置:首页-> 技术开发-> JSP学院->  jsp计数器代码

 jsp计数器代码
作者:admin 时间:2000-12-10  来自:ASP教程  选择阅读文体:


<!--
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);
%>




上一篇: jsp源码实例1(输出) 下一篇:jsp文件操作之读取篇

GoogLe中搜索“ jsp计数器代码”相关内容...
百 度 中搜索“ jsp计数器代码”相关内容...
一 搜 中搜索“ jsp计数器代码”相关内容...

相关文章

.Net专栏
Script
ASP学院
PHP学院
Web服务器
CGI学院
XML学院
SQL学院
JSP学院
SMS学院
提升QQ等级 QQ挂机升级外挂
国内首发 韩国版QQ自定义头像
挖掘Windows XP系统安装盘中的神秘宝藏
初见photoshop8.0的庐山真面目!
BT下载速度之战:Bitcomet对决比特精灵
腾讯最新漏洞-------QQ红钻任你拿
Windows XP 的安装
如何制作万能DVD
浅谈Windows XP SP2补丁包的安装及使用
RM,RMVB转VCD
购物车的源程序
Eclipse中使用ANT
JAVA/JSP学习系列之一(JDK安装)
Windows下JSP开发环境的配置
Java学习的捷径
J2EE 开发购物网站 经验篇 - 建表
实战 J2EE 开发购物网站 - 创建数据库
实战 J2EE 开发购物网站 二
JSP开发前菜鸟设置篇
用Java实现HTTP文件队列下载