[plt-scheme] more questions about plt web server

From: Zhu Chongkai (mathematica at citiz.net)
Date: Fri Jan 7 22:24:07 EST 2005

======= At 2005-01-08, 04:42:27 Larry White wrote: =======

>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>First, thanks for the help so far.  It's greatly appreciated.   This
>is the most fun i've had coding since i got paid to work in smalltalk.
>1. When writing servlets, what do you do with resources that should
>have application scope- things like a global hashtable for sessions or
>a db connection pool that need to persist across servlets,
>continuations, etc.  For the record, i can't use a single servlet with
>continuations to represent an entire session with my app because it
>would be too large.

I once met the same situation as you and managed just by launch the
web-server with "global variables".

The code looks like:

(require (lib "web-server.ss" "web-server"))

(define global-variable
;define your global hashtable, db connection pool, or 
;anything you want here

(define shut-down-the-server 
  (serve (load-configuration "the-path-of-your-config-file")))

And then in you servlets, just access the global-variable you
defined. But please note that servlets may be invoked concurrently
so you may need semaphore (or some equivalent) if you want to have
side-effects on global-variables.

I think this approach is easy. And actually, if I want to close the
web-server, I can do some thing on the global-variable (such as
disconnect to the db) by explict code on it befor or after call

>2. The smalltalk days referred to above came to an end because our
>chosen smalltalk used language threads in such a way that the entire
>application blocked on external function calls - like a database
>access for example.  Since that was where the web app spent most of
>its time, it could only handle one user at a time.  (I hear earlier
>versions of python had the same issue.)   Please tell me this isn't
>the case with mzscheme.
>Thanks again.

= = = = = = = = = = = = = = = = = = = =
Zhu Chongkai

Posted on the users mailing list.