亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

application對象統(tǒng)計所有用戶對某網頁的訪問次數

 更新時間:2013年08月28日 16:09:39   作者:  
使用application對象完成累計的功能統(tǒng)計所有用戶對某網頁的訪問次數,具體實現如下,喜歡的朋友可以參考下
因為使用application對象完成累計的功能,所以當

(1)當前的Wen應用重新部署
(2)Tomcat服務器重啟

計數器要重新開始計數。

jsp代碼如下:
復制代碼 代碼如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
//判斷application對象中有沒有保存名為count的參數
//如果沒有,在application對象中新增一個名為count的參數
if(application.getAttribute("count")==null){
application.setAttribute("count", new Integer(0));
}
Integer count = (Integer)application.getAttribute("count");
//使用application對象讀取count參數的值,再在原值基礎上累加1
application.setAttribute("count",new Integer(count.intValue()+1));
%>
<h2>
<!-- 輸出累加后的count參數對應的值 -->
歡迎您訪問,本頁面已經被訪問過 <font color="#ff0000"><%=application.getAttribute("count") %></font>次。。。。
</h2>
</body>
</html>

在瀏覽器輸入:http://localhost:8888/WebDemo/count.jsp
 
在需要計數的jsp文件中,包含該count.jsp即可。
復制代碼 代碼如下:

<%@include file="count.jsp" %>

相關文章

最新評論