当前位置:首页 > 网络编程 > WEB编程 > JSP >  jsp计数器代码

 jsp计数器代码

点击次数:22 次 发布日期:2008-11-26 15:52:19 作者:源代码网
源代码网推荐 <!--
源代码网推荐 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);
源代码网推荐 %>
源代码网推荐
源代码网推荐
源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华