我想统计有多少人访问了我的网站。应该如何统计呢我记得是在SESSION里面写个公共变量什么的
具体怎么写啊?
谢谢

解决方案 »

  1.   

    application里面记录点击次数啊, 然后写入数据库.
      

  2.   

    <%@ page contentType="text/html;charset=gb2312" language="java"%> 
    <%! 
    synchronized void countPeople() 

       ServletContext application=getServletContext(); 
       Integer number=(Integer)application.getAttribute("Count"); 
       if(number==null){ 
       number=new Integer(1); 
       application.setAttribute("Count",number); 
    }else{ 
       number=new Integer(number.intValue()+1); 
       application.setAttribute("Count",number); 
    }} %> 
    <% 
    if(session.isNew()) 
    {countPeople(); 
    Integer myNumber=(Integer)application.getAttribute("Count"); 
    session.setAttribute("MyCount",myNumber); 

    %><h3 align="center">您是第<font color="red"><% 
    int a; 
    if(session.getAttribute("MyCount")!=null) 
    {a=((Integer)session.getAttribute("MyCount")).intValue();} 
    else 
    {a=1;} 
      %><%=a %></font>个访问本站的客户。</h3> 
      

  3.   

    登录了就加1    session 就够了
      

  4.   

    可以交给第三方的流量统计厂商google的是免费的,在你的首页嵌入它提供的一段js脚本即可,登录google的统计分析站点可以看到你的网站的详细流量信息,很方便
      

  5.   

    同意楼上,用application大家认为可行吗?