网站访问计数器
来源:互联网 发布:网络远程教育大学报名 编辑:程序博客网 时间:2024/05/04 17:43
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%><%@ page import="java.io.*" %><%@ page import="java.util.*" %><%@ page import="java.math.*" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>访问人数计数器</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <%!//定义全局变量 BigInteger count = null; %> <%! public BigInteger load(File file){ BigInteger count = null; try{ if(file.exists()){ Scanner scan = null; scan = new Scanner(new FileInputStream(file)); if(scan.hasNext()){ count = new BigInteger(scan.next()); } scan.close(); }else{ count = new BigInteger("0"); save(file,count); } }catch(Exception e){ e.printStackTrace(); } return count; } public void save(File file, BigInteger count){ try{ PrintStream ps = null; ps = new PrintStream(new FileOutputStream(file)); ps.println(count); ps.close(); }catch(Exception e){ e.printStackTrace(); } } %> <% String filename = this.getServletContext().getRealPath("/")+"count.txt"; File file = new File(filename); if(session.isNew()){ synchronized(this){ count = load(file); count = count.add(new BigInteger("1")); save(file,count); } } %> <h2>你是第<%=count==null?0:count %>位访客</h2> </body></html>http://localhost:8080/login/count.jsp
0 0
- 网站访问计数器
- Golang 网站访问计数器
- 过滤器的使用实现网站访问计数器
- 通过application实现网站访问计数器
- 访问计数器
- 网站计数器
- 网站计数器
- 网站计数器
- 网站计数器
- 网站计数器
- ASPNET9月28日笔记:网站访问计数器
- 08-网站访问计数器(jsp内置对象)
- 20160410servlet学习笔记网站访问次数计数器
- jsp制作网站计数器(同一用户多次访问计数器只加一次)
- 访问页面的计数器
- RecordStore实现访问计数器
- Web访问计数器
- 简单的访问计数器
- IOS多线程开发
- iOS开发中@property的属性介绍
- 五、Sketchup用ruby进行二次开发--创建图形(面及pushpull、followMe方法的应用)
- 串的基本操作
- Cache学习(UC, WC)
- 网站访问计数器
- 浅谈 trie树 及其实现
- 中医养生馆加盟的口碑营销
- 黑马程序员_11_银行业务调度系统
- 排序算法
- Java compiler level does not match the version of the installed Java project facet
- hdu 1395 比较简单的数论题
- 数据库视频总结
- Java实现由前序序列和中序序列重建二叉树,并后序输出。