日期:2014-05-18  浏览次数:20768 次

jsp怎样编写在线统计人数的功能。
我编写一个Online.jsp,利用HttpSessionListener实现在线人数统计MySessionListener.java和PubFunction.java结果当直接关闭浏览器,无法显示及统计,请高手们帮个忙看看,谢谢。代码如下:
package   com.winlink.logo.util;

import   java.text.*;
import   java.util.*;
import   com.jspsmart.upload.*;
import   java.sql.Statement;
import   java.sql.ResultSet;
import   java.sql.DriverManager;

public   class   PubFunction   {
        public   PubFunction()   {
        }
       
        public   static   String   Null2Str(String   s)   {
                if   (s   ==   null)
                    s   =   " ";
                else
                    s   =   s.trim();
                return   s;
        }
       
        public   static   String   charsetConvert(String   s)
        {
              //   s=   s.replaceAll   ( " ' ", "\ " ");
                String   temp   =   null;
                try
                {
                        temp   =   new   String(s.getBytes( "ISO-8859-1 "),   "GB2312 ");
                }
                catch(Exception   e)   {   }
                    return   temp;
        }
       
        public   static   String   englishConvert(String   s)
        {
                String   temp   =   null;                
                try
                {
                        temp   =   new   String(s.getBytes( "GB2312 "),   "ISO-8859-1 ");
                }
                catch(Exception   e)   {   }
                    return   temp;
        }
       
        public   static   String   formateDate(Date   d)
        {
                SimpleDateFormat   sdf   =  
                        new   SimpleDateFormat( "yyyy-MM-dd   HH:mm