最新下载
热门教程
- 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%>个访问用户
相关文章
- 豆包官网网页版入口-豆包AI在线网页版入口 10-10
- 微信如何折叠发图 10-10
- 在Windows系统上使用Ollama部署DeepSeek模型的全过程实用指南 10-10
- Pycharm怎么注释多行代码?Alt+3快捷键快速搞定实用指南 10-10
- 超星学习通官网登录入口-学习通网页版官方直达通道 10-09
- 海角社区最新登录入口-2026海角官网在线登录地址 10-09