JSP中用application统计访客总人数

来源:互联网 发布:网络教育毕业都考不过 编辑:程序博客网 时间:2024/03/29 01:10
<% 

if(application.getAttribute("count")==null){ 
application.setAttribute("count", new Integer(0)); 
}  
Integer count = (Integer)application.getAttribute("count");  
application.setAttribute("count",new Integer(count.intValue()+1)); 
%> 
<h2> 
<!-- 输出累加后的count参数对应的值 --> 
本页面已经被访问过 <font color="#ff0000"><%=application.getAttribute("count") %></font>次。。。。 
</h2> 
0 0