JSP Counter Code

Source: Internet
Author: User
Tags integer readline
js| counter



<!--
Jsp-hitcounter counts sessions.
Copyright (C) Jesper Schmitz Mouridsen.
Visit Www.webappcabaret/jsm2/webapps.jsp?find=jsphcs for more info.

This are free software; Can redistribute it and/or modify it under the terms of the GNU general public License as published by the free Softwa Re Foundation; Either version 2 of the License, or (at your option) any later version.

This are distributed in the hope that it'll be useful and but without any WARRANTY; Without even the implied warranty of merchantability or FITNESS for A particular purpose. 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 ("FileWriter"));
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);
%>




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.