Global object that contains properties related to the current request.
| $req | Global object that contains properties related to the current request. |
| Properties | |
| authUser | If a “Basic” auth token is supplied ion the header, this function will return the username part, otherwise “”. |
| authPassword | If a “Basic” auth token is supplied ion the header, this function will return the password part, otherwise “”. |
| data | Stores parameters to the request. |
| handled | set this to true to prevent requested page from processing |
| headers | a JavaScript Object where the properties are header names and the property values are an array of strings containing each of request header’s values. |
| timeout | The maximum time in seconds this request should be allowed to run. |
| type | The type of http request. |
| rawData | Stores raw parameters to the request. |
| id | A unique identifier for this request |
| paramNames | A array of the parameter names passed to this request |
| contentText | content of the request body as a string |
| contentType | content type of the request |
| contentXml | content of the request body as an XML() object |
| contentByteArray | content of the request body as a Java byte[] |
If a “Basic” auth token is supplied ion the header, this function will return the username part, otherwise “”.
If a “Basic” auth token is supplied ion the header, this function will return the password part, otherwise “”.
Stores parameters to the request.
Every parameter in the HttpServletRequest is copied as a lowercase property of the data object.
If a parameter is passed multiple times, this property will be a comma-separated list of each value of the parameter. In addition, a property called <paramName>$array is created. This property contains an array of all the values of that parameter name, in the order they were passed. This parameter is created even if only one value is passed
If a parameter value can be interpreted as JSON, a property called <paramName>$object is created by calling String.parseJson against the value. If there are multiple JSON valid objects, only the last will be stored in parameter_name$object, but a property called parameter_name$objectArray is populated with every object created.
Every value in data.<paramName> and data.<paramName>$array is escaped via String.escapeHtml. This helps to protect against Cross-Site Scripting (XSS) and SQL injection. To access un-altered parameter data, see rawData
File uploads produce an object in $req.data containing information about the upload that looks like this
$req.data.<fieldname> ={
diskItem: org.apache.commons.fileupload.disk.DiskFileItem,
stats:{
fieldName:String, name of field in form,
fileName:String, name of file on client side,
contentType:String, mime type,
isInMemory:boolean, true if file contents are in memory,
sizeInBytes:int, size in bytes,
diskLocation:String, the current location of the uploaded file
}
}multiple uploads with the same fieldname are stored in $req.data.<fieldname>$array.
Upload progress can be tracked in a separate request/Thread via
var progress=$session.get("$uploadProgress");which returns a progress object.
| fileNumber | File number currently being uploaded |
| bytesRead | Bytes uploaded so far for this file |
| totalBytes | Total bytes to be uploaded for this file |
| percentComplete | Percent complete as a ratio, from 0 to 1 |
| kps | Upload rate in KiloBytes Per Second. Multiply this by 8 to get KiloBits per second |
| message | Generic message in the form of “Uploading file #1, 10% complete (200 KBps)”; |
| elapsedSeconds | total time in seconds since upload processing started |
a JavaScript Object where the properties are header names and the property values are an array of strings containing each of request header’s values.
Each header is keyed by how it appeared in the header, and as lowercase. This is because not every server formats header names the same. This means that if you are looking for a specific header, it is better to use
if ("user-agent" in $req.headers)rather than
if("User-Agent" in $req.headers)To avoid confusion when looping over key names, the lowercase key names are hidden and do not show up in Myna.dump() or $req.headers.getKeys()
The maximum time in seconds this request should be allowed to run. see “Default Request Timeout” in the administrator under General Settings. a value of 0 disables the timeout.
Stores raw parameters to the request.
This property contains the same content as data, but without any filtering through String.escapeHtml. Be very careful displaying this data in a web page as it may expose your site to Cross Site Scripting (XSS) exploits
replaces common symbols with their HTML entity equivalents
String.prototype.escapeHtml=function( string )