免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
java 防刷新 訪問量

<%@ page language="java" import="java.util.*,example.Configuration" pageEncoding="UTF-8"%>
<%
 Configuration conf = new Configuration();
 String getSeeesionId = (String) session.getAttribute("sessionId");
 String sessionId = session.getId();
 String visitNum = (String) session.getAttribute("visitNum");
 if (!sessionId.equals(getSeeesionId)) {
  //更新訪問數(shù)量
  conf.setValue();

  //獲取更新后的訪問數(shù)量
  visitNum = conf.getValue("visitNum");
 }
 session.setAttribute("sessionId", sessionId);
 session.setAttribute("visitNum", visitNum);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>瀏覽量統(tǒng)計(jì)</title>
 </head>
 <body>
  您是第<%=visitNum%>個(gè)訪問者
 </body>
</html>


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); //設(shè)置鍵值對
  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");//將未訪問設(shè)置為訪問
    session.setMaxInactiveInterval(60 * 60 * 24);//設(shè)置最大時(shí)效    單位是秒

    int count1 = Integer.parseInt(count);
    count1 = count1 + 1;
    count = String.valueOf(count1).toString();
    RecordCount.writeCount("C:/info1.txt", count);

   }
  %>

</body>

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
java http session狀態(tài)保持
Response 對象encodeURL 與encodeRedirectURL
我的shiro之旅: 六 自定義shiro的sessionId
jetty對sessionId的處理分析
webpy使用筆記(二) session/sessionid的使用
基于Session的身份竊取
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服