最新下载
热门教程
- 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%>个访问用户
相关文章
- AAI框架提出精算接口为AI代理动作定价并执行边界控制 05-30
- Java性能飞跃实录:从6500毫秒到49毫秒的内存布局优化实战 05-30
- 异环男女主角介绍 异环主要角色设定与人物关系解析 05-30
- CUA-Gym规模化可验证训练环境与任务,赋能计算机使用代理 05-30
- 星露谷物语怎么解锁地窖 星露谷物语地窖解锁指南分享 05-30
- 喵喵机怎么录题打印 05-30