Examining the Request
When the CSP server responds to an HTTP request, it packages information about the incoming request into the %request object, which is available on all CSP pages. This variable is an instance of %CSP.RequestOpens in a new tab.
Note that the CSP pages also have access to the %session object, which you can use to pass additional data from page to page.
URL
To find the URL (not including the query string) of an incoming HTTP request, use the URL property of the %request object:
Write "URL: ", %request.URL
URL Parameters
A URL may contain a list of parameters (also known as the URL query). The %request object makes these available via its Data property.
For example, suppose the incoming URL contains:
/csp/user/MyPage.csp?A=10&a=20&B=30&B=40
You can retrieve these parameters on the server using:
Write %request.Data("A",1) // this is 10
Write %request.Data("a",1) // this is 20
Write %request.Data("B",1) // this is 30
Write %request.Data("B",2) // this is 40
Data is a multidimensional property and each value stored within it has 2 subscripts: the name of the parameter and the index number of the parameter (parameters can occur multiple times within a URL as with B above). Note that parameter names are case-sensitive.
Also note that it does not matter if an incoming HTTP request is a GET or a POST request: the Data property represents the parameter values in exactly the same way.
You can use the ObjectScript $Data function to test if a given parameter value is defined:
If ($Data(%request.Data("parm",1))) {
}
If you wish to refer to a parameter but are not sure if it is defined, you can use the ObjectScript $Get function:
Write $Get(%request.Data("parm",1))
You can find out how many values are defined for a particular parameter name using the Count method of the %request object:
For i = 1:1:%request.Count("parm") {
Write %request.Data("parm",i)
}
The same techniques also work even when the parameter values are encrypted.
CGI Variables
The web server provides a set of values, referred to as CGI (Common Gateway Interface) environment variables, which contain information about the HTTP client and web server. You can get access to these CGI environment values using the multidimensional property CgiEnvs of the %request object. You can use this in the same manner as the Data property.
For example, to determine what type of browser is making the HTTP request, look at the value of the CGI environment variable HTTP_USER_AGENT:
Write %request.CgiEnvs("HTTP_USER_AGENT")
For information on the available CGI environment variables, see CGI Environment Variables.
MIME Data
An incoming request may contain MIME (Multipurpose Internet Mail Extensions) data. This is typically used for larger pieces of information, such as files. You can retrieve MIME data using the using the multidimensional property MimeData of the %request object.