欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jsp利用application統(tǒng)計(jì)在線人數(shù)的方法

 更新時(shí)間:2015年01月05日 11:01:18   投稿:shichen2014  
這篇文章主要介紹了jsp利用application統(tǒng)計(jì)在線人數(shù)的方法,代碼中備有較為詳盡的注釋便于理解,是比較實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了jsp利用application統(tǒng)計(jì)在線人數(shù)的方法。分享給大家供大家參考。

具體實(shí)現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
<%@ 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)//如果是第一個(gè)訪問者
{
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">簡(jiǎn)單的頁面訪問計(jì)數(shù)器</font>
  </p>
  <p>
  <font size="2" color="#000000">
  歡迎訪問此頁面,您是<%=number%>個(gè)訪問用戶
  </font>
  </p>
  </body>
</html>

希望本文所述對(duì)大家的jsp程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論