► |  | Web Server: PLT HTTP Server

1 | Running the Web Server
2 | Writing Servlets
3 | Extending the Web Server
4 | Troubleshooting and Tips
5 | Acknowledgements
| Index

► | 3 | Extending the Web Server

3.1 | Configuration
3.2 | Setting Up Servlets
3.3 | Dispatchers
3.4 | Web Config Unit
3.5 | Web Server Unit
3.6 | Internal

▼ | 3.1 | Configuration

3.1.1 | Configuration Table Structure
3.1.2 | Configuration Table
3.1.3 | Servlet Namespaces
3.1.4 | Standard Responders

► | 3.1.3 | Servlet Namespaces

3.1.3.1 | Why this is useful

On this page:

make-servlet-namespace/ c
make-make-servlet-namespace
3.1.3.1`` Why this is useful

Version: 4.1.4
top← prev up next →

##### 3.1.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-servlet-namespace/c : contract?

Equivalent to

(->* ()
(#:additional-specs (listof module-path?))
namespace?)

.

(make-make-servlet-namespace #:to-be-copied-module-specs to-be-copied-module-specs)
→ make-servlet-namespace/c
to-be-copied-module-specs : (listof module-path?)

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")))

##### 3.1.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.

top← prev up next →