JavaServer Pages



The earliest CGIs were written in a language called C. A sample CGI written in C is
shown in

Listing 1.1
. It generates a Web page that contains the current time and date.
Listing 1.1 A sample CGI in C
#include <stdio.h>
#include <time.h>

int main(int argc, char **argv) {
time_t now;

printf("<HTML>\n");
printf("<BODY>\n");

time(&now);
printf("The time is now: %s", ctime(&now));

printf("</BODY>\n");
printf("</HTML>\n");

exit(0);
}