Interface ExtensionPointHttpServletRequest


  • public interface ExtensionPointHttpServletRequest
    Interface used by the Extension Point to provide methods for HttpServletRequest
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String getCharacterEncoding()
      Returns the name of the character encoding used in the body of this request.
      int getContentLength()
      Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
      String getContentType()
      Returns the MIME type of the body of the request, or null if the type is not known.
      String getContextPath()
      Returns the portion of the request URI that indicates the context of the request.
      long getDateHeader​(String name)
      Returns the value of the specified request header as a long value that represents a Date object.
      String getHeader​(String name)
      Returns the value of the specified request header as a String.
      Iterator<String> getHeaderNames()
      Returns an iterator of all the header names this request contains.
      Iterator<String> getHeaders​(String name)
      Returns all the values of the specified request header as an Enumeration of String objects.
      InputStream getInputStream()
      Retrieves the body of the request as binary data using a InputStream.
      int getIntHeader​(String name)
      Returns the value of the specified request header as an int.
      Locale getLocale()
      Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
      String getMethod()
      Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
      ExtensionParameters getParameters()
      Get the parameters for this request.
      Part getPart​(String name)
      Gets the Part with the given name.
      Collection<Part> getParts()
      Gets all the Part components of this request, provided that it is of type multipart/form-data.
      String getPathInfo()
      String getPathInfo() Returns any extra path information associated with the URL the client sent when it made this request.
      String getProtocol()
      Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
      String getQueryString()
      Returns the query string that is contained in the request URL after the path.
      BufferedReader getReader()
      Retrieves the body of the request as character data using a BufferedReader.
      String getRemoteAddr()
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      String getRemoteHost()
      Returns the fully qualified name of the client or the last proxy that sent the request.
      String getRemoteUser()
      Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
      String getRequestURI()
      Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
      StringBuffer getRequestURL()
      Reconstructs the URL the client used to make the request.
      String getScheme()
      Returns the name of the scheme used to make this request, for example, http, https, or ftp.
      String getServerName()
      Returns the host name of the server to which the request was sent.
      int getServerPort()
      Returns the port number to which the request was sent.
      String getServletPath()
      Returns the part of this request's URL that calls the servlet.
      Object getSessionAttribute​(String name)
      Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes.
      Iterator<String> getSessionAttributeNames()
      Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes.
      void invalidateSession()
      Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes.
      boolean isMultipartFormDataRequest()
      Convenience method to determine if this request is a multipart/form-data request.
      boolean isRequestedSessionIdValid()
      Checks whether the requested session ID is still valid.
      boolean isSecure()
      Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
      void removeSessionAttribute​(String name)
      Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes.
      void setCharacterEncoding​(String env)
      Overrides the name of the character encoding used in the body of this request.
      void setSessionAttribute​(String name, Object value)
      Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes.
    • Method Detail

      • getDateHeader

        long getDateHeader​(String name)
        Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.

        The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.

        If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.

        Parameters:
        name - a String specifying the name of the header
        Returns:
        a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the request
        Throws:
        IllegalArgumentException - If the header value can't be converted to a date
      • getHeader

        String getHeader​(String name)
        Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the request. The header name is case insensitive. You can use this method with any request header.
        Parameters:
        name - a String specifying the header name
        Returns:
        a String containing the value of the requested header, or null if the request does not have a header of that name
      • getHeaders

        Iterator<String> getHeaders​(String name)
        Returns all the values of the specified request header as an Enumeration of String objects.

        Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

        If the request did not include any headers of the specified name, this method returns an empty Iterator. The header name is case insensitive. You can use this method with any request header.

        Parameters:
        name - a String specifying the header name
        Returns:
        an Iterator containing the values of the requested header. If the request does not have any headers of that name return an empty iterator. If the container does not allow access to header information, return null
      • getHeaderNames

        Iterator<String> getHeaderNames()
        Returns an iterator of all the header names this request contains. If the request has no headers, this method returns an empty iterator.

        Some servlet containers do not allow servlets to access headers using this method, in which case this method returns null

        Returns:
        an iterator of all the header names sent with this request; if the request has no headers, an empty iterator; if the servlet container does not allow servlets to use this method, null
      • getIntHeader

        int getIntHeader​(String name)
        Returns the value of the specified request header as an int. If the request does not have a header of the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a NumberFormatException.

        The header name is case insensitive.

        Parameters:
        name - a String specifying the name of a request header
        Returns:
        an integer expressing the value of the request header or -1 if the request doesn't have a header of this name
        Throws:
        NumberFormatException - If the header value can't be converted to an int
      • getMethod

        String getMethod()
        Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.
        Returns:
        a String specifying the name of the method with which this request was made
      • getContextPath

        String getContextPath()
        Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string. This is based on the ContextURL to ensure operability with RMJ
        Returns:
        a String specifying the portion of the request URI that indicates the context of the request
      • getPathInfo

        String getPathInfo()
        String getPathInfo() Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character. This method returns null if there was no extra path information. Same as the value of the CGI variable PATH_INFO.
        Returns:
        a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information
      • getQueryString

        String getQueryString()
        Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.
        Returns:
        a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.
      • getRemoteUser

        String getRemoteUser()
        Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER.
        Returns:
        a String specifying the login of the user making this request, or null if the user login is not known
      • getRequestURI

        String getRequestURI()
        Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example:
        Examples of Returned Values
        First line of HTTP request Returned Value
        POST /some/path.html HTTP/1.1 /some/path.html
        GET http://foo.bar/a.html HTTP/1.0 /a.html
        HEAD /xyz?a=b HTTP/1.1 /xyz

        To reconstruct an URL with a scheme and host, use getRequestURL().

        This is based on the ContextURL to ensure operability with RMJ

        Returns:
        a String containing the part of the URL from the protocol name up to the query string
      • getRequestURL

        StringBuffer getRequestURL()
        Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

        Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append query parameters.

        This method is useful for creating redirect messages and for reporting errors. This is based on the ContextURL to ensure operability with RMJ

        Returns:
        a StringBuffer object containing the reconstructed URL
      • getServletPath

        String getServletPath()
        Returns the part of this request's URL that calls the servlet. This path starts with a "/" character and includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME.

        This method will return an empty string ("") if the servlet used to process this request was matched using the "/*" pattern. This is based on the ContextURL to ensure operability with RMJ

        Returns:
        a String containing the name or path of the servlet being called, as specified in the request URL, decoded, or an empty string if the servlet used to process the request is matched using the "/*" pattern.
      • isRequestedSessionIdValid

        boolean isRequestedSessionIdValid()
        Checks whether the requested session ID is still valid.
        Returns:
        true if this request has an id for a valid session in the current session context; false otherwise
      • getCharacterEncoding

        String getCharacterEncoding()
        Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding
        Returns:
        a String containing the name of the character encoding, or null if the request does not specify a character encoding
      • setCharacterEncoding

        void setCharacterEncoding​(String env)
                           throws UnsupportedEncodingException
        Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().
        Parameters:
        env - a String containing the name of the character encoding.
        Throws:
        UnsupportedEncodingException - if this is not a valid encoding
      • getContentLength

        int getContentLength()
        Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_LENGTH.
        Returns:
        an integer containing the length of the request body or -1 if the length is not known
      • getContentType

        String getContentType()
        Returns the MIME type of the body of the request, or null if the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.
        Returns:
        a String containing the name of the MIME type of the request, or null if the type is not known
      • getProtocol

        String getProtocol()
        Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL. This is based on the ContextURL to ensure operability with RMJ
        Returns:
        a String containing the protocol name and version number
      • getScheme

        String getScheme()
        Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738. This is based on the ContextURL to ensure operability with RMJ
        Returns:
        a String containing the name of the scheme used to make this request
      • getServerName

        String getServerName()
        Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the Host header value, if any, or the resolved server name, or the server IP address. This is be based on the ContextURL to ensure operability with RMJ
        Returns:
        a String containing the name of the server
      • getServerPort

        int getServerPort()
        Returns the port number to which the request was sent. It is the value of the part after ":" in the Host header value, if any, or the server port where the client connection was accepted on. This is based on the ContextURL to ensure operability with RMJ
        Returns:
        an integer specifying the port number
      • getRemoteAddr

        String getRemoteAddr()
        Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
        Returns:
        a String containing the IP address of the client that sent the request
      • getRemoteHost

        String getRemoteHost()
        Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.
        Returns:
        a String containing the fully qualified name of the client
      • getLocale

        Locale getLocale()
        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. This will be based on the user locale that is performing the request
        Returns:
        the preferred Locale for the client
      • isSecure

        boolean isSecure()
        Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. This is based on the ContextURL to ensure operability with RMJ
        Returns:
        a boolean indicating if the request was made using a secure channel
      • getSessionAttribute

        Object getSessionAttribute​(String name)
        Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes. These Attributes behave like HttpSession Attributes, but are only available to the ExtensionPoint storing them. Returns the object bound with the specified name in this session, or null if no object is bound under the name.
        Parameters:
        name - a string specifying the name of the object
        Returns:
        the object with the specified name
        Throws:
        IllegalStateException - if this method is called on an invalidated session
      • getSessionAttributeNames

        Iterator<String> getSessionAttributeNames()
        Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes. These Attributes behave like HttpSession Attributes, but are only available to the ExtensionPoint storing them. Returns an Enumeration of String objects containing the names of all the objects bound to this session.
        Returns:
        an Enumeration of String objects specifying the names of all the objects bound to this session
        Throws:
        IllegalStateException - if this method is called on an invalidated session
      • setSessionAttribute

        void setSessionAttribute​(String name,
                                 Object value)
        Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes. These Attributes behave like HttpSession Attributes, but are only available to the ExtensionPoint storing them. Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

        After this method executes, and if the new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application.

        If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called.

        If the value passed in is null, this has the same effect as calling removeAttribute().

        Parameters:
        name - the name to which the object is bound; cannot be null
        value - the object to be bound
        Throws:
        IllegalStateException - if this method is called on an invalidated session
      • removeSessionAttribute

        void removeSessionAttribute​(String name)
        Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes. These Attributes behave like HttpSession Attributes, but are only available to the ExtensionPoint storing them. Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.

        After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound. The container then notifies any HttpSessionAttributeListeners in the web application.

        Parameters:
        name - the name of the object to remove from this session
        Throws:
        IllegalStateException - if this method is called on an invalidated session
      • getParameters

        ExtensionParameters getParameters()
        Get the parameters for this request. The returned object contains the parameters and some convience methods specific to Extension Points.
        Returns:
        the ExtesionParameters object
      • invalidateSession

        void invalidateSession()
        Since there is no access to the HttpSession, an alternative method is provided to store HttpSession Attributes. These Attributes behave like HttpSession Attributes, but are only available to the ExtensionPoint storing them. Invalidates this session then unbinds any objects bound to it. This only applies to the Attributes for this Extension Point, and the user will not be logged out.
        Throws:
        IllegalStateException - if this method is called on an already invalidated session
      • isMultipartFormDataRequest

        boolean isMultipartFormDataRequest()
        Convenience method to determine if this request is a multipart/form-data request. These requests are normally used to upload files. When this method return true, the getParts() and getPart() method are safe to call. otherwise those methods throw exceptions.
        Returns:
        true when this is a multipart/form-data request, false when it is not.
      • getParts

        Collection<Part> getParts()
                           throws IOException,
                                  IllegalStateException
        Gets all the Part components of this request, provided that it is of type multipart/form-data. If this request is of type multipart/form-data, but does not contain any Part components, the returned Collection will be empty. Any changes to the returned Collection must not affect this HttpServletRequest.
        Returns:
        a (possibly empty) Collection of the Part components of this request
        Throws:
        IOException - if an I/O error occurred during the retrieval of the Part components of this request
        IllegalStateException - if the request body is larger than maxRequestSize, or any Part in the request is larger than maxFileSize, or if if this request is not of type multipart/form-data
      • getPart

        Part getPart​(String name)
              throws IOException,
                     IllegalStateException
        Gets the Part with the given name.
        Parameters:
        name - the name of the requested Part
        Returns:
        The Part with the given name, or null if this request is of type multipart/form-data, but does not contain the requested Part
        Throws:
        IOException - if an I/O error occurred during the retrieval of the requested Part
        IllegalStateException - if the request body is larger than maxRequestSize, or any Part in the request is larger than maxFileSize or if this request is not of type multipart/form-data