可以用脚本控制刷新时间,逻辑处理可以由JSP 来完成

解决方案 »

  1.   

    用javascript 定时刷新, 处理过程用jsp搞定~~~
      

  2.   

    写个TimerTask再用servlet做控制不就行了
      

  3.   

    我一般都这么实现定时触发一个servelet就是了,在servelet里你可以查数据库了,干别的也成呀
    package com.goodman;import java.net.URL;
    import java.io.*;
    import java.net.*;public class TimerListener
        implements javax.servlet.ServletContextListener {
      private java.util.Timer timer;
      long iVoxCount = 0;
      long iMsgCount = 0;
      private java.io.InputStream is = null;  public TimerListener() {
        System.out.println("初始化成功");
        timer = new java.util.Timer(true);
      }
      public void contextDestroyed(javax.servlet.ServletContextEvent event) {
        System.out.println("系统关闭");
        timer.cancel();
      }  public void contextInitialized(javax.servlet.ServletContextEvent event) {
        System.out.println("开始检测");
        //System.out.println( event.getServletContext().getRealPath( "/" ) );
        timer.schedule( new java.util.TimerTask() {
          private HttpURLConnection conn;
          public void run() {
                   try {          URL url = new URL("激发的servelet路径");
              try {
                conn = (HttpURLConnection) url.openConnection();
                is = conn.getInputStream();
                is.close();
                conn.disconnect();
              }
              catch (IOException ex1) {
              }
            }
            catch (MalformedURLException ex) {
            }
          }
        }
        , 1000, 20000);//20000是时间间隔,毫秒
      }
    }