// Time Server
// Each request to the special file
// "time" will cause time.htm to 
// get the current time and 
// then serve that file name
// probably not safe for multiple accesses!
import java.util.*;
import java.io.*;

public class TimeHttp extends HttpServer {
  public String action(String fn, Hashtable vars) {
    try {
      if (fn.equals("/time")) {
        PrintWriter tout=
          new PrintWriter(
          new FileWriter(props.getProperty("root")+"/time.htm"));
        Date d=new Date();
        tout.println(d);
        tout.close();
        return "/time.htm";
        }
       }
      catch (Exception e) { 
       System.out.println("Except: " + e);
       return "err.htm"; }
      return fn;
     }

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

  }
   
