@ProviderType public interface SlingHttpServletRequest extends javax.servlet.http.HttpServletRequest, Adaptable
SlingHttpServletRequest
defines the interface to provide
client request information to a servlet.
Request Parameters Generally request parameters are transmitted as
part of the URL string such as GET /some/path?param=value
or as request data of content type application/x-www-form-urlencoded
or multipart/form-data. The Sling Framework must decode parameters
transferred as request data and make them available through the various
parameter accessor methods. Generally parameters transferred as
multipart/form-data will be accessed by one of the methods returning
RequestParameter
instances.
In any case, the ServletRequest.getReader()
and ServletRequest.getInputStream()
methods
will throw an IllegalStateException
if called after any methods
returning request parameters if the request content type is either
application/x-www-form-urlencoded or multipart/form-data
because the request data has already been processed.
Starting with Sling API 2.0.6, this interface als extends the
Adaptable
interface.
Modifier and Type | Method and Description |
---|---|
@Nullable javax.servlet.http.Cookie |
getCookie(java.lang.String name)
Returns the named cookie from the HTTP request or
null if
no such cookie exists in the request. |
@Nullable javax.servlet.RequestDispatcher |
getRequestDispatcher(@NotNull Resource resource)
Same as
getRequestDispatcher(Resource,RequestDispatcherOptions)
but using empty options. |
@Nullable javax.servlet.RequestDispatcher |
getRequestDispatcher(@NotNull Resource resource,
RequestDispatcherOptions options)
Returns a
RequestDispatcher object that acts as a wrapper
for the resource located at the given resource. |
@Nullable javax.servlet.RequestDispatcher |
getRequestDispatcher(@NotNull java.lang.String path,
RequestDispatcherOptions options)
Returns a
RequestDispatcher object that acts as a wrapper
for the resource located at the given path. |
@Nullable RequestParameter |
getRequestParameter(@NotNull java.lang.String name)
Returns the value of a request parameter as a
RequestParameter ,
or null if the parameter does not exist. |
@NotNull java.util.List<RequestParameter> |
getRequestParameterList()
Returns the request parameters as instances of the
RequestParameter interface in the order or the request where the
query string parameters are first and the POST request parameters are
second. |
@NotNull RequestParameterMap |
getRequestParameterMap()
Returns a
Map of the parameters of this request. |
@Nullable RequestParameter[] |
getRequestParameters(@NotNull java.lang.String name)
Returns an array of
RequestParameter objects containing all of
the values the given request parameter has, or null if the
parameter does not exist. |
@NotNull RequestPathInfo |
getRequestPathInfo()
Returns the
RequestPathInfo pertaining to this request. |
@NotNull RequestProgressTracker |
getRequestProgressTracker()
Returns the
RequestProgressTracker of this request. |
@NotNull Resource |
getResource()
Returns the
Resource object on whose behalf the servlet acts. |
@Nullable java.util.ResourceBundle |
getResourceBundle(java.util.Locale locale)
Returns the resource bundle for the given locale.
|
@Nullable java.util.ResourceBundle |
getResourceBundle(java.lang.String baseName,
java.util.Locale locale)
Returns the resource bundle of the given base name for the given locale.
|
@NotNull ResourceResolver |
getResourceResolver()
Returns the
ResourceResolver which resolved the
resource of this request. |
@Nullable java.lang.String |
getResponseContentType()
Returns the framework preferred content type for the response.
|
@NotNull java.util.Enumeration<java.lang.String> |
getResponseContentTypes()
Gets a list of content types which the framework accepts for the
response.
|
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
@NotNull @NotNull Resource getResource()
Resource
object on whose behalf the servlet acts.Resource
object of this request.@NotNull @NotNull ResourceResolver getResourceResolver()
ResourceResolver
which resolved the
resource
of this request.@NotNull @NotNull RequestPathInfo getRequestPathInfo()
RequestPathInfo
pertaining to this request.@Nullable @Nullable RequestParameter getRequestParameter(@NotNull @NotNull java.lang.String name)
RequestParameter
,
or null
if the parameter does not exist.
This method should only be used if the parameter has only one value. If
the parameter might have more than one value, use
getRequestParameters(String)
.
If this method is used with a multivalued parameter, the value returned
is equal to the first value in the array returned by
getRequestParameters
.
This method is a shortcut for
getRequestParameterMap().getValue(String)
.
name
- a String
specifying the name of the parameterRequestParameter
representing the single value of the
parameterjava.lang.IllegalArgumentException
- if name is null
.getRequestParameters(String)
,
RequestParameterMap.getValue(String)
@Nullable @Nullable RequestParameter[] getRequestParameters(@NotNull @NotNull java.lang.String name)
RequestParameter
objects containing all of
the values the given request parameter has, or null
if the
parameter does not exist.
If the parameter has a single value, the array has a length of 1.
This method is a shortcut for
getRequestParameterMap().getValues(String)
.
name
- a String
containing the name of the parameter
the value of which is requestedRequestParameter
objects containing the
parameter values.java.lang.IllegalArgumentException
- if name is null
.getRequestParameter(String)
,
RequestParameterMap.getValues(String)
@NotNull @NotNull RequestParameterMap getRequestParameterMap()
Map
of the parameters of this request.
The values in the returned Map
are from type
RequestParameter
array (RequestParameter[]
).
If no parameters exist this method returns an empty Map
.
Map
containing parameter names as
keys and parameter values as map values, or an empty
Map
if no parameters exist. The keys in the
parameter map are of type String. The values in the parameter map
are of type RequestParameter
array (RequestParameter[]
).@NotNull @NotNull java.util.List<RequestParameter> getRequestParameterList()
RequestParameter
interface in the order or the request where the
query string parameters are first and the POST request parameters are
second.RequestParameter
in request declaration
order.@Nullable @Nullable javax.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull java.lang.String path, RequestDispatcherOptions options)
RequestDispatcher
object that acts as a wrapper
for the resource located at the given path. A
RequestDispatcher
object can be used to include the
resource in a response.
Returns null
if a RequestDispatcher
cannot
be returned for any reason.
path
- a String
specifying the pathname to the
resource. If it is relative, it must be relative against the
current servlet.options
- influence the rendering of the included ResourceRequestDispatcher
object that acts as a wrapper
for the resource
or null
if an
error occurs preparing the dispatcher.@Nullable @Nullable javax.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull Resource resource, RequestDispatcherOptions options)
RequestDispatcher
object that acts as a wrapper
for the resource located at the given resource. A
RequestDispatcher
object can be used to include the
resource in a response.
Returns null
if a RequestDispatcher
cannot
be returned for any reason.
resource
- The Resource
instance whose response content may
be included by the returned dispatcher.options
- influence the rendering of the included ResourceRequestDispatcher
object that acts as a wrapper
for the resource
or null
if an
error occurs preparing the dispatcher.@Nullable @Nullable javax.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull Resource resource)
getRequestDispatcher(Resource,RequestDispatcherOptions)
but using empty options.resource
- The Resource
instance whose response content may
be included by the returned dispatcher.RequestDispatcher
object that acts as a wrapper
for the resource
or null
if an
error occurs preparing the dispatcher.@Nullable @Nullable javax.servlet.http.Cookie getCookie(java.lang.String name)
null
if
no such cookie exists in the request.name
- The name of the cookie to return.null
if no such cookie exists.@Nullable @Nullable java.lang.String getResponseContentType()
For included resources this method will returned the same string as
returned by the ServletResponse.getContentType()
without
the character set.
@NotNull @NotNull java.util.Enumeration<java.lang.String> getResponseContentTypes()
For included resources this method will returned an enumeration
containing a single entry which is the same string as returned by the
ServletResponse.getContentType()
without the character
set.
@Nullable @Nullable java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
locale
- the locale for which to retrieve the resource bundle. If
this is null
, the locale returned by
ServletRequest.getLocale()
is used to select the resource bundle.@Nullable @Nullable java.util.ResourceBundle getResourceBundle(java.lang.String baseName, java.util.Locale locale)
baseName
- The base name of the resource bundle to returned. If this
parameter is null
, the same resource bundle
must be returned as if the getResourceBundle(Locale)
method is called.locale
- the locale for which to retrieve the resource bundle. If
this is null
, the locale returned by
ServletRequest.getLocale()
is used to select the resource bundle.@NotNull @NotNull RequestProgressTracker getRequestProgressTracker()
RequestProgressTracker
of this request.Copyright © 2018 The Apache Software Foundation. All rights reserved.