Web Overview

A web server is just a machine connected to the Internet, running a computer program that listens to requests for content, such as HTML files. Those requests come from client programs, such as browsers, running on other computers also connected to the Internet. For this to work, there has to be an agreed language for both the requests and what's sent back. That language is the HyperText Transfer Protocol (HTTP).

Rather than repeat what's been written many times, I refer you to

Web Servers with Lisp

The nice thing about the web is that all communication between programs is done using HTTP, which uses simple commands in plain text. That simplicity means that you can write a web server or browser in any language you like, as long as it lets you read and write to the network.

Writing a server or browser from scratch would be pretty tedious, though. Fortunately, many languages now have code libraries to take care of such details as reading and writing characters to the network, parsing HTTP commands, creating threads (lightweight parallel processes) for each request to support simultaneous users, and so on.

For Common Lisp there are several major code libraries for web services:

In this course, we will use Franz, Inc.'s AServe library, because:

For those students not using Allegro, there is a portable AServe library that runs in a number of Common Lisp's. I use it in LispWorks Personal Edition.

How to Test AServe

If you are using the EECS 325 starter files, you already have AServe loaded and ready to use. If not,

Then do the following to run the test code:

8000 is a port. Ports are simply numbers operating systems use as a kind of address to determine which program should process a network message. Low numbers are pre-assigned to standard services, e.g., 80 is the default for a web server. For development, use a safe high number. In the unlikely case that your machine is already using port 8000 for some service, try some other number over 1024. Use that number in your localhost URL.

If you have a firewall running on your machine, and you should, the first time you start the server, you may get an alert saying that your Lisp is trying to access the network. Tell your firewall this is OK.

The URL http://localhost:8000/ should take you to the default AllegroServe page. If it doesn't, look at the error message you got in the browser.

test-aserve.lisp. defines the following example pages:

These are all very simple examples. You can look at the code in test-aserve.lisp to see how AServe is used. In this class, however, we will use Webactions. Webactions is a framework for web sites built on top of, and included with, AServe. For information on using Webactions in this class, see this writeup.

Shut Down AServe

While your server is running, any machine on the Internet can access your pages. To access your server from another machine, replace localhost with your server's Internet name or IP address. For example, if your machine's IP address was 555.100.10.100, then you could critique Lisp by typing this URL in your browser:

http://555.100.10.100:8000/critic

Note: if you have a private IP address, you will need to get and use the public one to access your server. To see your public address, click here.

To avoid hackers attacking your system, and to reduce system load, shut down AServe when testing is done:

(net.aserve:shutdown)
Quitting Lisp will also shutdown the server.

For more examples, see:

Faculty: Chris Riesbeck
Time: Monday, Wednesday, Friday: 1pm - 2pm
Location:Annenberg G15

Contents

Important Links