<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>统计页面访问次数</title>
</head>
<body>
<%
//step1 获得本页面已经被访问的次数
Object temp= application.getAttribute("count");
int count=0; //本页面的访问次数
if(temp!=null){ //此页面不是第一次访问
count=(Integer)temp;
count++; //step2 不是第一次访问,次数+1
}else {
//此页面是第一次访问 ,application中没有保存访问次数,此时该值就是null
count = 1;
}
//step3 保存最近的访问次数
application.setAttribute("count",count);
%>
本页面的访问次数是:<%=count%>