Generating HTTP responses

The result of evaluating the top-level expressions of a web page script becomes the HTTP response that the servlet sends back to the browser. The result is typically an HTML/XML element code object Kawa will automatically format the result as appropriate for the type. Before the main part of the response there may be special "response header values", as created by the response-header function. Kawa will use the response header values to set various required and optional fields of the HTTP response. Note that response-header does not actually do anything until it is "printed" to the standard output. Note also that a "Content-Type" response value is special since it controls the formatting of the following non-response-header values.

Procedure: response-header key value

Create the response header ‘key: value’ in the HTTP response. The result is a "response header value" (of some unspecified type). It does not directly set or print a response header, but only does so when you actually "print" its value to the response output stream.

Procedure: response-content-type type

Species the content-type of the result - for example "text/plain". Convenience function for (response-header "Content-Type" type).

Procedure: error-response code [message]

Creates a response-header with an error code of code and a response message of message. (For now this is the same as response-status.)

Note this also returns a response-header value, which does not actually do anything unless it is returned as the result of executing a servlet body.

Procedure: response-status code [message]

Creates a response-header with an status code of code and a response message of message. (For now this is the same as error-response.)