HTTP-Related Functions in the Request and Session Modules

(1Q18)


This article describes the functions for handling HTTP session parameters and variables.

Introduction

The request module (in the http://exist-db.org/xquery/request function namespace) contains functions for handling HTTP request parameters. The session module (in the http://exist-db.org/xquery/session function namespace) contains functions for handling HTTP session variables. Functions in these namespaces are only usable if the query is executed through the XQueryGenerator or the XQueryServlet.

Available functions

request:get-parameter(name, default value)

This HTTP function expects two arguments: the first denotes the name of the parameter, the second specifies a default value, which is returned if the parameter is not set. This function returns a sequence containing the values for the parameter.

request:get-uri()

This function returns the URI of the current request. To encode this URI using the current session identifier, use the following function:

session:encode-url(request:get-uri())
session:create()

This function creates a new HTTP session if none exists.

Other session functions read and set session attributes, among other operations. For example, an XQuery or Java object value can be stored in a session attribute, to cache query results.