/*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.sling.api;
 
 
 
The 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 org.apache.sling.api.request.RequestParameter instances.

In any case, the javax.servlet.ServletRequest.getReader() and javax.servlet.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 org.apache.sling.api.adapter.Adaptable interface.

 
 public interface SlingHttpServletRequest extends HttpServletRequestAdaptable {

    
Returns the org.apache.sling.api.resource.Resource object on whose behalf the servlet acts.

Returns:
The Resource object of this request.
 
     Resource getResource();

    
Returns the org.apache.sling.api.resource.ResourceResolver which resolved the resource of this request.

Returns:
The resource resolver
 
Returns the org.apache.sling.api.request.RequestPathInfo pertaining to this request.

Returns:
the request path info.
 
Returns the value of a request parameter as a org.apache.sling.api.request.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(java.lang.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).

Parameters:
name a String specifying the name of the parameter
Returns:
a org.apache.sling.api.request.RequestParameter representing the single value of the parameter
Throws:
java.lang.IllegalArgumentException if name is null.
See also:
getRequestParameters(java.lang.String)
org.apache.sling.api.request.RequestParameterMap.getValue(java.lang.String)
Returns an array of org.apache.sling.api.request.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).

Parameters:
name a String containing the name of the parameter the value of which is requested
Returns:
an array of org.apache.sling.api.request.RequestParameter objects containing the parameter values.
Throws:
java.lang.IllegalArgumentException if name is null.
See also:
getRequestParameter(java.lang.String)
org.apache.sling.api.request.RequestParameterMap.getValues(java.lang.String)
Returns a Map of the parameters of this request.

The values in the returned Map are from type org.apache.sling.api.request.RequestParameter array (RequestParameter[]).

If no parameters exist this method returns an empty Map.

Returns:
an immutable 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 org.apache.sling.api.request.RequestParameter array (RequestParameter[]).
Returns a 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.

Parameters:
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 Resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource or null if an error occurs preparing the dispatcher.
            RequestDispatcherOptions options);

    
Returns a 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.

Parameters:
resource The org.apache.sling.api.resource.Resource instance whose response content may be included by the returned dispatcher.
options influence the rendering of the included Resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource or null if an error occurs preparing the dispatcher.
            RequestDispatcherOptions options);

    
Returns the named cookie from the HTTP request or null if no such cookie exists in the request.

Parameters:
name The name of the cookie to return.
Returns:
The named cookie or null if no such cookie exists.
    Cookie getCookie(String name);

    
Returns the framework preferred content type for the response. The content type only includes the MIME type, not the character set.

For included resources this method will returned the same string as returned by the ServletResponse.getContentType() without the character set.

Returns:
preferred MIME type of the response
    String getResponseContentType();

    
Gets a list of content types which the framework accepts for the response. This list is ordered with the most preferable types listed first. The content type only includes the MIME type, not the character set.

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.

Returns:
ordered list of MIME types for the response
Returns the resource bundle for the given locale.

Parameters:
locale the locale for which to retrieve the resource bundle. If this is null, the locale returned by javax.servlet.ServletRequest.getLocale() is used to select the resource bundle.
Returns:
the resource bundle for the given locale
    ResourceBundle getResourceBundle(Locale locale);

    
Returns the resource bundle of the given base name for the given locale.

Parameters:
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(java.util.Locale) method is called.
locale the locale for which to retrieve the resource bundle. If this is null, the locale returned by javax.servlet.ServletRequest.getLocale() is used to select the resource bundle.
Returns:
the resource bundle for the given locale
    ResourceBundle getResourceBundle(String baseNameLocale locale);

    
New to GrepCode? Check out our FAQ X