** Start of listing of h2-java.cgi ** ** End of listing of h2-java.cgi ** Here is the directory entry for that file: ^ Note user execute permission needed for all CGI scripts. ** Start of listing of H2.java ** import java.util.Date; import java.text.SimpleDateFormat; import java.util.Properties; import java.util.Enumeration; public class H2 { public static void main(String args[]) { System.out.println("Content-type: text/plain"); System.out.println(""); Properties pr = System.getProperties(); Enumeration en = pr.propertyNames(); while (en.hasMoreElements()) { Object oKey = en.nextElement(); String sKey = (String)oKey; String sVal = pr.getProperty(sKey); //System.out.println("Key[" + sKey + "] -> [" + sVal + "]"); } String rm = pr.getProperty("cgi.request_method"); System.out.println("** Request method is " + rm); if ("GET".equals(rm)) { System.out.println("Good! I can do GET."); } else { System.out.println("Bad, I do only GET, can't do " + rm); return ; } String qs = pr.getProperty("cgi.query_string"); System.out.println("** Query string is " + qs); System.out.println(""); if ((qs.toLowerCase().indexOf("date")) < 0) { System.out.println("You didn't mention 'date' this time."); } else { long lTime = System.currentTimeMillis(); //System.out.println("Current millisecond count = " + lTime); Date dt = new Date(lTime); //System.out.println("Date object is " + dt); SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MMM.dd HH:mm:ss"); //System.out.println("DateFormat is " + sdf); String strTime = sdf.format(dt); System.out.println("The date&time is currently " + strTime + " in California."); } System.out.println(""); if ((qs.toUpperCase().indexOf("IP")) < 0) { System.out.println("You didn't mention 'IP' this time."); } else { String ra = pr.getProperty("cgi.remote_addr"); System.out.println("The IP number " + ra + " is where your " + "client/browser is located."); } System.out.println(""); if ((qs.toLowerCase().indexOf("name")) < 0) { System.out.println("You didn't mention 'name' this time."); } else { System.out.println("My name is 'Robert Elton Maas'"); } } } ** End of listing of H2.java ** Here is the directory entry for that source file and its compilation: -rw------- 1 rem user 2040 Jul 16 2005 H2.java -rw------- 1 rem user 2292 Jul 16 2005 H2.class ^ Note user execute permission *not* needed for separate program files.