java 网站访问量的简单统计(防止刷新)
来源:互联网 发布:unity 删除 数组对象 编辑:程序博客网 时间:2024/06/05 16:39
RecordCount.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class RecordCount
{
//使用Properties
private static Properties pp=new Properties();
public static void writeCount(String path,String count)
{
pp.setProperty("count", count); //设置键值对
try {
pp.store(new FileOutputStream(path), ""); //写入文件
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static String readCount(String path)
{
String count="0";
File f = new File(path);
if (!f.exists())
{
writeCount(path, "0");
}
try {
pp.load(new FileInputStream(path));
count=pp.getProperty("count");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return count;
}
}
jsp 页面:
<%@page import="cn.zgcyx.RecordCount"%>
<body>
<!--在需要的地方插入下面代码-->
<%
String count = RecordCount.readCount("C:/info1.txt");
if (session.getAttribute("visit") == null) {
session.setAttribute("visit", "y");//将未访问设置为访问
session.setMaxInactiveInterval(60 * 60 * 24);//设置最大时效 单位是秒
int count1 = Integer.parseInt(count);
count1 = count1 + 1;
count = String.valueOf(count1).toString();
RecordCount.writeCount("C:/info1.txt", count);
}
%>
</body>
- java 网站访问量的简单统计(防止刷新)
- java统计网站访问量
- java统计网站访问量
- java jsp实现网站访问量的统计
- 网站访问量的统计
- java实现网站访问量统计
- 页面访问量和网站访问量的统计
- 统计网站当天的访问量
- 网站访问量的统计方式
- 统计网站页面的访问量
- 统计java网站访问量和在线人数
- java 统计网站访问量&在线人数
- mysql统计网站每天的访问量
- 使用ServletContext对象统计网站的访问量
- 统计网站访问量的小例子
- 使用ServletContext对象统计网站的访问量
- 通过COOKIE统计网站的访问量
- jsp统计页面访问量和刷访问量的简单使用
- iOS沙盒(sandbox)机制及获取沙盒路径
- Socket阻塞与非阻塞,同步与异步
- 【计算机视觉】借助图像直方图来检测特定物(MeanShift、CamShift算法)
- sqlserver 获取表的字段名及类型
- 几种c/c++中字符串转整形的方法
- java 网站访问量的简单统计(防止刷新)
- Android 虚线分割线
- how tomcat works 读书笔记(二)----------一个简单的servlet容器
- 阿里巴巴离职DBA职业生涯总结--吕海波
- java md5加密函数
- vs2008配置JQuery智能提示步骤
- 参加香港亚洲秋季电子展经验点滴拾遗
- python字符乱码的问题。
- 常用的基于区域的局部匹配准则 SAD、SSD、NCC