// hi2CGIplus.java // Compile using: $ javac "hi2CGIplus.java" // // 09-DEC-97 MGD initial // // Quick demonstration of using the CGIplus class for a "CGIplus" script. // Can be invoked using ... http://host/cgiplus-bin/hi2cgiplus.class import java.io.*; public class hi2cgiplus { private static CGIplus cgienv = new CGIplus(); private static String lastUsageTime = null; public static void main (String args[]) { /* CGIplus "infinite loop" */ for (;;) { cgienv.begin(); // CGI-compliant header line making document HTML (and pre-expired) System.out.print("Content-Type: text/html\n" + "Expires: Thu, 01-Jan-1970 00:00:01 GMT\n\n"); if (cgienv.getCgiVar("WWW_KEY_1") != null) { System.out.print("
It\'s currently " + cgienv.getCgiVar("WWW_REQUEST_TIME_LOCAL") + " here at " + cgienv.getCgiVar("WWW_SERVER_NAME") + ""); System.out.print("
This Java CGIplus script has been used "); if (cgienv.getUsageCount() == 1) { System.out.print("once (use again!)"); } else { System.out.print(cgienv.getUsageCount() + " times, last at " + lastUsageTime + "\n"); } System.out.print("
Notice the difference in latency " +
"after it's been loaded! " +
"
To see that again click here (script exits requiring reload).");
lastUsageTime = cgienv.getCgiVar("WWW_REQUEST_TIME_LOCAL");
cgienv.end();
}
}
}