Common scripting variables
The basic objects, such as the request and response, are available for all scripting languages.
Name |
Description |
request |
SlingHttpServletRequest object, providing access to the HTTP request header information - extends the standard HttpServletRequest - but also to Sling-specific things like resource, selectors, etc. |
response |
SlingHttpServletResponse object, providing access for the HTTP response that is created by the server. This is currently the same as the HttpServletResponse from which it extends. |
sling |
SlingScriptHelper , containing convenience methods for scripts, mainly sling.include('/some/other/resource') for including the responses of other resources inside this response (eg. embedding header html snippets) and sling.getService(foo.bar.Service.class) to retrieve OSGi services available in Sling (Class notation depending on scripting language). |
resource |
Current Resource to handle, depending on the URL of the request. Same as request.getResource(). |
reader |
Direct access to the Reader of the request - same as request.getReader(). Use it for reading the data of an HTTP request body. |
out |
Direct access to the PrintWriter of the response - same as response.getWriter(). Use it for writing to the HTTP response body. |
flush |
Indicates whether the output used by the script shall be flushed after the script evaluation ended. It is a Boolean, so use TRUE for flushing or FALSE for not flushing, which is the default value. The boolean value notation depends on the scripting language. |
log |
Provides an SLF4J Logger for logging to the Sling log system from within scripts, eg. log.info("Executing my script"). |
See also the api documentation of the org.apache.sling.api.scripting.SlingBindings.java
which defines the common scripting variables.