您的位置:首页-> 资讯中心-> JSP技术-> JSP->  jsp计数器代码

JSP

JSP

本类阅读TOP10

·用JSP文件上载轻松实现
·用JSP编写文件上传
·jsp留言板源代码一: 给jsp初学者.
·JSP数据库操作例程(Use Bean)
· jsp计数器代码
·JSP发送邮件实例
·jsp留言板源代码三: 给jsp初学者.
·jsp文件操作之读取篇
·配置Web应用环境实现JSP留言簿
·jsp文件操作之追加篇

精品推荐
 jsp计数器代码

加入时间:2005-2-22 快乐下载

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





相关文章

相关软件