要求:一个用户多次刷新, 不计入点击量,
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>网页点击量</title>
</head>
<body>
<%
int count=0;
if (application.getAttribute("count")==null){
count=count+1;
application.setAttribute("count",count);
out.println("您是该页面的第1个访客");
}
else{
count=(Integer)application.getAttribute("count");
if(session.isNew()==true){
count++;
}
application.setAttribute("count", count);
out.println("<h1>点击量:"+count+"</h1>");
}
%>
</body>
</html>