Class ServletRequest

All Implemented Interfaces:
DispatchRequest, Request

Servlet-based implementation of the TilesApplicationContext interface.

Copied from Apache tiles-request-servlet 1.0.7 and adapted for Jakarta EE 9.

  • Constructor Details

  • Method Details

    • getHeader

      Return an immutable Map that maps header names to the first (or only) header value (as a String).
      Returns:
      The header map.
    • getResponseHeaders

      Return an add-able object that can be used to write headers to the response.
      Returns:
      An add-able object.
    • getHeaderValues

      Return an immutable Map that maps header names to the set of all values specified in the request (as a String array). Header names must be matched in a case-insensitive manner.
      Returns:
      The header values map.
    • getParam

      Return an immutable Map that maps request parameter names to the first (or only) value (as a String).
      Returns:
      The parameter map.
    • getParamValues

      Return an immutable Map that maps request parameter names to the set of all values (as a String array).
      Returns:
      The parameter values map.
    • getContext

      public Map<String,Object> getContext(String scope)
      Returns a context map, given the scope name.

      This method always return a map for all the scope names returned by getAvailableScopes(). That map may be writable, or immutable, depending on the implementation.

      Parameters:
      scope - The name of the scope.
      Returns:
      The context.
    • getRequestScope

      Returns the context map from request scope.
      Returns:
      the context map from request scope
    • getSessionScope

      Returns the context map from session scope.
      Returns:
      the context map from session scope
    • getAvailableScopes

      Returns all available scopes.

      The scopes are ordered according to their lifetime, the innermost, shorter lived scope appears first, and the outermost, longer lived scope appears last. Besides, the scopes "request" and "application" always included in the list.

      Returns:
      All the available scopes.
    • doForward

      public void doForward(String path) throws IOException
      Forwards to a path.
      Specified by:
      doForward in class AbstractClientRequest
      Parameters:
      path - The path to forward to.
      Throws:
      IOException - If something goes wrong when forwarding.
    • doInclude

      public void doInclude(String path) throws IOException
      Includes the content of a resource (servlet, JSP page, HTML file) in the response. In essence, this method enables programmatic server-side includes.
      Specified by:
      doInclude in class AbstractClientRequest
      Parameters:
      path - a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.
      Throws:
      IOException - if the included resource throws this exception
      See Also:
    • getOutputStream

      Returns a ServletOutputStream suitable for writing binary data in the response. The servlet container does not encode the binary data.
      Returns:
      a ServletOutputStream for writing binary data
      Throws:
      IllegalStateException - if the getWriter method has been called on this response
      IOException - if an input or output exception occurred
      See Also:
    • getWriter

      public Writer getWriter() throws IOException
      Returns a Writer object that can send character text to the client. The Writer uses the character encoding returned by ServletResponse.getCharacterEncoding(). If the response's character encoding has not been specified as described in getCharacterEncoding (i.e., the method just returns the default value ISO-8859-1), getWriter updates it to ISO-8859-1.
      Returns:
      a Writer object that can return character data to the client
      Throws:
      UnsupportedEncodingException - if the character encoding returned by getCharacterEncoding cannot be used
      IllegalStateException - if the getOutputStream method has already been called for this response object
      IOException - if an input or output exception occurred
      See Also:
    • getPrintWriter

      Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding returned by ServletResponse.getCharacterEncoding(). If the response's character encoding has not been specified as described in getCharacterEncoding (i.e., the method just returns the default value ISO-8859-1), getWriter updates it to ISO-8859-1.
      Returns:
      a PrintWriter object that can return character data to the client
      Throws:
      UnsupportedEncodingException - if the character encoding returned by getCharacterEncoding cannot be used
      IllegalStateException - if the getOutputStream method has already been called for this response object
      IOException - if an input or output exception occurred
      See Also:
    • isResponseCommitted

      public boolean isResponseCommitted()
      Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.
      Returns:
      a boolean indicating if the response has been committed
      See Also:
    • setContentType

      public void setContentType(String contentType)
      Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, >text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called before getWriter is called.
      Parameters:
      contentType - a String specifying the MIME type of the content
      See Also:
    • getRequestLocale

      Returns the preferred Locale that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server.
      Returns:
      the preferred Locale for the client
      See Also:
    • getRequest

      Returns the request object to use.
      Returns:
      the request object to use
    • getResponse

      Returns the response object to use.
      Returns:
      the response object to use
    • isUserInRole

      public boolean isUserInRole(String role)
      Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.
      Parameters:
      role - a String specifying the name of the role
      Returns:
      a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated
      See Also: