On this page:
make-make-servlet-namespace
4.3.1 Why this is useful
Version: 4.1

4.3 Servlet Namespaces

 (require web-server/configuration/namespace)

"configuration/namespace.ss" provides a function to help create the make-servlet-namespace procedure needed by the make functions of "dispatchers/dispatch-servlets.ss" and "dispatchers/dispatch-lang.ss".

(make-make-servlet-namespace #:to-be-copied-module-specs to-be-copied-module-specs)

 

 

(key-> ([additional-specs (listof module-spec?)])

       namespace?)

  to-be-copied-module-specs : (listof module-spec?)

This function creates a function that when called will construct a new namespace that has all the modules from to-be-copied-module-specs and additional-specs, as well as mzscheme and mred, provided they are already attached to the (current-namespace) of the call-site.

Example:

  (make-make-servlet-namespace

   #:to-be-copied-module-specs `((lib "database.ss" "my-module")))

4.3.1 Why this is useful

A different namespace is needed for each servlet, so that if servlet A and servlet B both use a stateful module C, they will be isolated from one another. We see the Web Server as an operating system for servlets, so we inherit the isolation requirement on operating systems.

However, there are some modules which must be shared. If they were not, then structures cannot be passed from the Web Server to the servlets, due to a subtlety in the way MzScheme implements structures.

Since, on occasion, a user will actually wanted servlets A and B to interact through module C. A custom make-servlet-namespace can be created, through this procedure, that attaches module C to all servlet namespaces. Through other means (see Dispatchers) different sets of servlets can share different sets of modules.