► |  | 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

▼ | 2 | Writing Servlets

2.1 | Defining a Servlet
2.2 | APIs
2.3 | Common Contracts
2.4 | HTTP
2.5 | Web Interaction
2.6 | Stateless Web Interaction
2.7 | Web Cells
2.8 | File Boxes
2.9 | Stateless Web Parameters
2.10 | Formlets
2.11 | Templates
2.12 | Continuation Managers

On this page:

k-url?
response-generator/ c
expiration-handler/ c
embed/ url/ c

Version: 4.1.4
top← prev up next →

#### 2.3`` Common Contracts

(require web-server/servlet/servlet-structs)

"servlet/servlet-structs.ss" provides a number of contracts for use in servlets.

k-url? : contract?

Equivalent to string?.

Example: "http://localhost:8080/servlets;1*1*20131636/examples/add.ss"

response-generator/c : contract?

Equivalent to (-> k-url? response?).

Example:

(lambda (k-url)
`(html
(body
(a ([href ,k-url])
"Click Me to Invoke the Continuation!"))))

expiration-handler/c : contract?

Equivalent to (or/c false/c (-> request? response?)).

Example:

(lambda (req)
`(html (head (title "Expired"))
(body (h1 "Expired")
(p "This URL has expired. "
"Please return to the home page."))))

embed/url/c : contract?

Equivalent to (opt-> ((-> request? any/c)) (expiration-handler/c) string?).

This is what send/suspend/dispatch gives to its function argument.

top← prev up next →