最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jsp 利用application统计在线人数代码
时间:2022-06-29 00:16:06 编辑:袖梨 来源:一聚教程网
jsp教程 利用application统计在线人数代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
application
<%!
Integer number;//
synchronized void numberVisiter()
{
ServletContext application = getServletContext();
Integer num = (Integer)application.getAttribute("count");
if(num == null)//如果是第一个访问者
{
num = new Integer(1);
application.setAttribute("count",num);
}
else
{
num = new Integer(num.intValue() + 1);
application.setAttribute("count",num);
}
}
%>
<%
if(session.isNew())
{
numberVisiter();
Integer number = (Integer)application.getAttribute("count");
}
%>
简单的页面访问计数器
欢迎访问此页面,您是<%=number%>个访问用户
相关文章
- 勇者斗恶龙破限乱斗官宣 2026年4月21日登陆移动端,Roguelite动作新作 04-16
- QQ经典版轻量版下载安装最新版-QQ经典版稳定版app官方入口免费下载 04-16
- 抖音网页版入口在哪-抖音电脑版官网一键直达 04-16
- 解密冰堡包 一把喷火又砸汉堡的狂想曲霰弹枪 04-16
- 异环医院第三层通关指南 04-16
- 虫虫漫画-免费海量正版漫画在线畅读 04-16