[plt-scheme] Web Server Novice Questions

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Sun Aug 25 23:28:28 EDT 2002

Hi Alex,

> Looking at the sample add.ss:
> 
> * Why are there two levels of call to send/suspend?

There are, depending on how you look at it, two or three calls to
SEND/SUSPEND (henceforth, S/S).  There are two static calls (ie,
instances in the source text) and three dynamic ones (ie, actual
invocations at run-time).  The first two dynamic invocations
correspond to the call in REQUEST-NUMBER.  The third dynamic
invocation is the one at the end of the program.

The first two dynamic invocations are to read the first and second
number, respectively.  The third one is really an artifact of the way
the Web server is currently defined.  By having the third one there,
you can backtrack to change the second number you entered and click
submit again, for instance.  Don't worry yourself too much about this
to understand how the server works; indeed, if you remove it and
experiment, you'll see what effect it has (if not why it's there).

> * Where does the value for k-url come from?

That's what S/S provides.  That is, K-URL is simply a local name; we
use that naming convention to remind ourselves of two things:

- the value *is* a URL (hence `url')
- the value *represents* continuation stored in the server (hence `k')

At any rate, you provide S/S a procedure that consumes one argument.
It provides that procedure a continuation URL, to be used in a form's
action field.  It is conventional to call this argument K-URL, but you
can call it anything else (RESUMER, say).

> * How does the server know which user is which? Is there a hidden
> session cookie?

No.  That's the beauty of S/S.  For now, I wouldn't even worry about
how it happens.  Just get practice with S/S first.  You don't need to
know how it happens to know that it happens.

Shriram



Posted on the users mailing list.