RSBScript Built-In (Special) Items
In addition to items declared within the script, several pre-existing items are available in the scope of an RSBScript. You can use these to access other useful information. They are:
- Input Item (_input) The input for a script can be read from the "_input" item. Not only does this item have the input available from the HTTP request (see next entry), but it also has values from rules such as the default values specified in Info. The "_input" item is the default top level item for any script: if you read values from the default item in a script, you are reading values from "_input". Note that, inside an rsb:call block, _input is no longer the default item and you must reference it by name if you need access to it.
- HTTP Request (_request)
You can access variables passed into the URL query string or POSTed to the script as attributes of the "_request" item. The _request item allows you to access three collections of name-value pairs: the "qstring", "form", and "server" collections. As the names indicate, these collections allow you to read values from the query string, from the form data, or from server variables associated with the current request. To access a specific collection, you can use its name as the prefix to the attribute you want to read. For example, "[_request.qstring:name]" reads the value of the variable "name" in the query string and "[_request.form:name]" reads the value of the variable "name" in the form data.
Apart from the collections described above, _request also allows you to read the raw contents (body) of the request by using _request.body.
Note: RSSBus automatically adds any variable found in the URL query string to the default input item (_input) when the script is executed. If a variable of the same name exists in the POST data, it overrides the value from the query string.
- RSSBus Profile (_profile) If you have access to the RSSBus profile, you can read profile entries using the _profile item. See the RSSBus Profile for details.
- ASP.NET Session (_session) ASP.NET session variables are available in RSBScript through the "_session" item. Any object stored in the session can be accessed as attributes of this item. The attribute name represents the key used to store the object in the session.
- Log Item (_log) Use the _log item to log messages. If the administrator has configured RSSBus logging, the messages will be written to the log. If RSSBus logging is not configured, the messages will be ignored. The log item has two attributes: "info" and "error". Setting a value to either of these attributes will write that value to the corresponding log. Reading a value from these attributes will return the last value written. See the section Logging and Diagnostics for more details.
- Saved Feeds (_feeds) You can access saved feeds (i.e., those saved using the save parameter of rsb:call as attributes of the special "_feeds" item).
- Feed Outputs (_out[n]) The default output item for the rsb:call keyword can also be accessed through a named special item, "_outX", where X is the level of nesting of rsb:call keywords. For example, if you are inside a single rsb:call keyword, the item's name will be "_out1";. If you are inside three levels of nested rsb:call keywords, then it will be _out3.
- Response Item (_response])
The response item allows the script writer to write directly to the HTTP response. You can set the attributes listed below in the response item. This item is normally used in RSSBus Templates. Note that it is not recommended to write directly to the response while authoring service scripts.
- "cookie:*": The cookie attribute allows you to set cookies in the response. The name of the attribute will be the name of the cookie, and the value of the attribute will be the value.
- "writetofile": Setting a path to the "writetofile" attribute writes the content of that path to the response.
- "redirect": Setting a value attribute in the response sends the redirect header to client browser. This can be used to redirect the browser to another URL.
- "statuscode": The status code attribute can be used to set the HTTP status code of the response.
- "statusdescription": The status description attribute can be used to set the HTTP status description of the response.
- HttpHeaders Item (_httpheaders)
The "_httpheaders" item provides easy access to HTTP headers in scripts and templates. You can read the HTTP request headers by reading from this item and write to the outgoing response headers by writing to this item. A common use for the "_httpheaders" item is to set the content-type for templates. To do this, add the following at the top of the script:
<rsb:set item="_httpheaders" attr="content-type" value="application/xml"/>
- Context Item (_context) The "_context" item contains the items that are held in the RSBContext at any given time. The "_context" item allows you to see all the other items that can be referenced by name.
- About Item (_about) The "_about" item gives you more information about your RSSBus installation. Its output tells you the version, serial number, etc. To see a list of all attributes and their values, use [_about.*].