<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>
<title>application</title>
</head>
<body>
<%!
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");
}
%>
<p>
<font size="2" color="blue">简单的页面访问计数器</font>
</p>
<p>
<font size="2" color="#000000">
欢迎访问此页面,您是<%=number%>个访问用户
</font>
</p>
</body>
</html>
相关文章:
- JSP最常用的五种内置对象(out,request,response,session,application) 2018-01-18
- 利用CORDIC算法计算三角函数 2021-03-02
- 利用Python学习线性代数 -- 1.1 线性方程组 2019-11-24
- oracle中LAG()和LEAD()等分析统计函数的使用方法(统计月增长率) 2021-08-05
- jsp中引入JavaScript的方法 2021-11-13
- 在线天数计算器 2021-12-12