标题:这样做统计网页访客数量的计数器可以吗?
只看楼主
小猪笨笨
Rank: 1
等 级:新手上路
帖 子:109
专家分:0
注 册:2006-4-19
 问题点数:0 回复次数:1 
这样做统计网页访客数量的计数器可以吗?

在书上看到的,不过我感觉不行,大家给点意见

<body>
<%! int count=0;%>
<%
String usercount;
request.getSession(true);
if(session.isNew())
{
count++;
usercount=String.valueOf(count);
session.putValue("usercount",usercount);
}
out.print("您是本站的第<font color=red size=5>");
out.print(session.getValue("usercount"));
out.print("</font>位访客");
%>
</body>

我认为不行是因为:当一个访客A登录后(假设是第1个访客),又有一个新的访客B(刚才没登录),那么代码中的count 和 usercount的值都会+1的,这时候A刷新网页的时候,他就应该变成第3位访客了

搜索更多相关主题的帖子: 计数器 访客 网页 数量 统计 
2006-05-10 09:40
可可℃乐
Rank: 2
等 级:新手上路
威 望:3
帖 子:1054
专家分:0
注 册:2006-5-9
得分:0 
大哥,我运行了一下,怎么哪次都是第一位呢..?
不会增加呀.???

[url=http://www.]网页设计教程[/url]
2006-05-12 19:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-63011-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.805422 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved