jsp計數(shù)器代碼
更新時間:2006年10月13日 00:00:00 作者:
<!--
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-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);
%>
相關(guān)文章
AJAX 自學練習 無刷新提交并修改數(shù)據(jù)庫數(shù)據(jù)并顯示
對應在數(shù)據(jù)庫中表格 rocars表的msg_id,ccrn兩個字段?,F(xiàn)在要實現(xiàn)在界面上修改ccrn的值,ajax提交到response.jsp頁面,并調(diào)用RocarsEntiy.updateCcrn方法更新對應的ccrn,最后無刷新顯示2009-09-09jsp的注釋可能會影響頁面加載速度讓代碼扔繼續(xù)執(zhí)行
注釋里面的java代碼還是會得到執(zhí)行,可以再查看頁面源代碼上看到執(zhí)行完成的內(nèi)容2014-10-10JSP Servelet 數(shù)據(jù)源連接池的配置
在高版本的Tomcat中有的可以省略第2步,有的則不能,如果不能則會引發(fā)異常,找不到驅(qū)動類2009-07-07jsp request.getParameter() 和request.getAttribute()方法區(qū)別詳解
這篇文章主要介紹了jsp request.getParameter() 和request.getAttribute()方法區(qū)別詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-08-08JSP 自定義標簽實現(xiàn)數(shù)據(jù)字典的實例
這篇文章主要介紹了JSP 自定義標簽實現(xiàn)數(shù)據(jù)字典的實例的相關(guān)資料,這里實現(xiàn)這樣的功能,希望能幫助到大家,需要的朋友可以參考下2017-08-08