// This server subclass uses a string to send the browser
// dynamic content
import java.util.*;
import java.io.*;

public class Time1Http extends HttpServer {
  private boolean process=false;  // special request?
  public String action(String fn, Hashtable vars) {
      if (fn.equals("/time")) {
        process=true;
        return "/time.htm"; // fake name
        }
      process=false;
      return fn;
      }

    public DataInputStream openFile(String fn, Hashtable vars) 
      throws IOException {
      if (process) {
         String res = new Date().toString();
// StringBufferInputStream is deprecated, but can't use StringReader
// without changing base class
         return new DataInputStream(new StringBufferInputStream(res));
         }
      else 
// do original code
         return super.openFile(fn,vars);
    }

    public static void main(String[] args) {
        new Time1Http();
    }

  } 
