Interface HttpRequest


  • public interface HttpRequest
    Framework-agnostic definition of an HTTP request.
    Since:
    9.16
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getContextPath()
      Returns the portion of the request URI that indicates the context of the request.
      Cookie[] getCookies()
      Returns an array containing all of the Cookie objects the client sent with this request.
      java.lang.String getHeader​(java.lang.String name)
      Returns the value of the specified request header as a String.
      java.util.Enumeration<java.lang.String> getHeaderNames()  
      java.util.Enumeration<java.lang.String> getHeaders​(java.lang.String name)
      Returns all the values of the specified request header as an Enumeration of String objects.
      java.lang.String getMethod()
      Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
      java.lang.String getParameter​(java.lang.String name)
      Returns the value of a request parameter as a String, or null if the parameter does not exist.
      java.lang.String[] getParameterValues​(java.lang.String name)
      Returns an array containing all the values the given request parameter has, or null if the parameter does not exist.
      java.lang.String getQueryString()
      Returns the query string that is contained in the request URL after the path.
      java.io.BufferedReader getReader()
      Retrieves the body of the request as character data using a BufferedReader.
      java.lang.String getRemoteAddr()
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      java.lang.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.
      java.lang.String getRequestURL()
      Returns the URL the client used to make the request.
      java.lang.String getScheme()
      Returns the name of the scheme used to make this request, for example, http, https, or ftp.
      java.lang.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.
      java.lang.String getServletPath()
      Returns the part of this request's URL that calls the servlet.
      boolean isSecure()
      Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
      void setAttribute​(java.lang.String name, java.lang.Object value)
      Stores an attribute in this request.
    • Method Detail

      • getServerPort

        int getServerPort()
        Returns the port number to which the request was sent.
      • isSecure

        boolean isSecure()
        Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
      • getScheme

        java.lang.String getScheme()
        Returns the name of the scheme used to make this request, for example, http, https, or ftp.
      • getServerName

        java.lang.String getServerName()
        Returns the host name of the server to which the request was sent.
      • getRequestURL

        java.lang.String getRequestURL()
        Returns 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.
      • getRequestURI

        java.lang.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.
      • getQueryString

        java.lang.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.
      • getContextPath

        java.lang.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.
      • getParameter

        java.lang.String getParameter​(java.lang.String name)
        Returns the value of a request parameter as a String, or null if the parameter does not exist. You should only use this method when you are sure the parameter has only one value. If the parameter might have more than one value, use getParameterValues(java.lang.String).
      • getParameterValues

        java.lang.String[] getParameterValues​(java.lang.String name)
        Returns an array containing all the values the given request parameter has, or null if the parameter does not exist.
      • getHeader

        java.lang.String getHeader​(java.lang.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.
      • getHeaderNames

        java.util.Enumeration<java.lang.String> getHeaderNames()
      • getHeaders

        java.util.Enumeration<java.lang.String> getHeaders​(java.lang.String name)
        Returns all the values of the specified request header as an Enumeration of String objects.
      • getMethod

        java.lang.String getMethod()
        Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
      • getCookies

        Cookie[] getCookies()
        Returns an array containing all of the Cookie objects the client sent with this request.
      • getRemoteAddr

        java.lang.String getRemoteAddr()
        Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      • setAttribute

        void setAttribute​(java.lang.String name,
                          java.lang.Object value)
        Stores an attribute in this request. Attributes are reset between requests.
      • getServletPath

        java.lang.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.
      • getReader

        java.io.BufferedReader getReader()
                                  throws java.io.IOException
        Retrieves the body of the request as character data using a BufferedReader. The reader translates the character data according to the character encoding used on the body.
        Throws:
        java.io.IOException