jsp计数器代码

2016-01-29 12:04 57 1 收藏

jsp计数器代码,jsp计数器代码

【 tulaoshi.com - Java 】

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

 

来源:https://www.tulaoshi.com/n/20160129/1484465.html

延伸阅读
标签: ASP
  <% bUseImages = CBool(Request.QueryString("images")) strCountFileName = Server.MapPath(Request.ServerVariables("SCRIPT_NAME") & ".dat") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ' Open the file as a text stream (1 = ForReading, True = Create) S...
标签: ASP
<% dim fso,f,no,I '定义变量绝对是个好习惯 Set fso = CreateObject("Scripting.FileSystemObject") '建立对象的实例 Set f = fso.OpenTextFile(Server.MapPath("count.no"), 1, True) '建立文本文件,打开为只读. if f.AtEndOfStream then '判断这个文件是否不存在 no=1 else no=f.ReadLine no=no+1 end if f.Close set f=fso.O...
标签: PHP
       <?php         $counterFile = "balong.txt";//存储数值的文件名几路径      function displayCounter($counterFile) {    $fp = fopen($counterFile,"rw");    $num = fgets($fp,5);    $num +...
标签: PHP
  最近嘉新的计数器改成文本的了,不过正好.. //count.php -js 应用版 <? $a=file("http://www.jx.zj.cninfo.net/cgi-bin/count.cgi?df=wfnic.dat"); print "document.write('<b$a[0]</b');"; ? //php 直接版 <? $a=file("http://www.jx.zj.cninfo.net/cgi-bin/count.cgi?df=wfnic.dat"...
标签: ASP
  网页计数器DIY 随着网络大行其道,网页计数器也流行起来。事实上大多数网站均有网页计数器,用以反映该网站的访问量。计数器的来源很广,Frontpage等网页编辑器自带了网页计数器,有的站点也提供免费的计数器下载。其实熟悉了ASP编程后,自己做一个计数器很容易。下面介绍一种实现方法。 计数器原理是:在第一次使用网页时置初始值1,以...

经验教程

941

收藏

61

精华推荐

php的计数器程序

php的计数器程序

白白白白灬痴

轻松打造ASP计数器

轻松打造ASP计数器

苏夜末萨

改进的IP计数器

改进的IP计数器

源人

微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部