...
The basic objects, such as the request and response, are available for all most scripting languages (Note the differences for eg. JSP below).
Name | Description |
---|---|
request | SlingHttpServletRequest object, providing access to the HTTP request header information - extends the standard HttpServletRequest - but also provides access to Sling-specific things like resource, path info, selector, 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 |
resource | Current Resource to handle, depending on the URL of the request. Same as |
currentNode | If the current |
reader | Direct access to the Reader of the request - same as |
out | Direct access to the PrintWriter of the response - same as |
flush | Indicates whether the output used by the script shall be flushed after the script evaluation ended. It is a Boolean, so use |
log | Provides an SLF4J Logger for logging to the Sling log system from within scripts, eg. |
See also the api documentation of the org.apache.sling.api.scripting.SlingBindings.java which defines the common scripting variables.
JSP
Since JSPs already have a few Java-objects pre-defined, things have to be named differently here. And you will have to explicitly require the variables to be defined with a custom tag <sling:defineObjects />
. Your jsp should start with:
Code Block |
---|
<%@ page session="false" %>
<%@ page import="javax.jcr.*,
org.apache.sling.api.resource.Resource"
%>
<%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %>
<sling:defineObjects />
|
slingRequest | SlingHttpServletRequest object, providing access to the HTTP request header information - extends the standard HttpServletRequest - but also provides access to Sling-specific things like resource, path info, selector, etc. |
slingResponse | 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. |
request | The standard JSP request object which is a pure HttpServletRequest. |
response | The standard JSP response object which is a pure HttpServletResponse. |
resourceResolver | Current ResourceResolver. Same as |
sling | SlingScriptHelper, containing convenience methods for scripts, mainly |
resource | Current Resource to handle, depending on the URL of the request. Same as |
currentNode | If the current |
log | Provides an SLF4J Logger for logging to the Sling log system from within scripts, eg. |