Lecture 12a: Web Servers and CGI

What You Will Learn Today

  1. Explain the purpose and types of web server software.
  2. Explain the function of server-side scripts and CGI scripts.
  3. Describe the Perl scripting language and its use in CGI scripting.
  4. Describe Java Server Pages, Java Beans and Servlets.

Web Server Software

Server-Side Scripts

CGI Scripts

Perl

#!/usr/bin/perl

print "Hello, world!\n"; 
#!/usr/bin/perl
$date = `date`;
print qq{Content-type: text/html\n\n<html>
  <head><title> Hello world! </title></head>
  <body>
  <h1> Hello world! </h1>
  <p> The current time on the server is: $date </p>
  </body>
  </html> 
};
#!/usr/local/bin/perl
 
print "Content-type: text/html\n\n";
while (($key, $val) = each %ENV) {
  print "$key = $val<BR>\n";
}

Java Server Pages

<html>
<head><title>Date JSP</title></head>
<body>
<h1>Date JSP</h1>
<p>The current time on the server is:
<%= new java.util.Date() %>
</p>
</body>
</html>

Java Beans

Servlets

To Do After Class