Interface WebContext


public interface WebContext
This interface represents the web context to use HTTP request and response.
Since:
1.4.0
Author:
Jerome Leleu
  • Method Details

    • getRequestParameter

      Optional<String> getRequestParameter(String name)
      Return a request parameter.
      Parameters:
      name - name of the parameter
      Returns:
      the request parameter
    • getRequestParameters

      Map<String,String[]> getRequestParameters()
      Return all request parameters.
      Returns:
      all request parameters
    • getRequestAttribute

      Optional getRequestAttribute(String name)
      Return a request attribute.
      Parameters:
      name - the name of the attribute
      Returns:
      the attribute
    • setRequestAttribute

      void setRequestAttribute(String name, Object value)
      Save a request attribute.
      Parameters:
      name - the name of the attribute
      value - the attribute
    • getRequestHeader

      Optional<String> getRequestHeader(String name)
      Return a request header.
      Parameters:
      name - name of the header
      Returns:
      the request header
    • getRequestMethod

      String getRequestMethod()
      Return the request method.
      Returns:
      the request method
    • getRemoteAddr

      String getRemoteAddr()
      Return the remote address.
      Returns:
      the remote address.
    • setResponseHeader

      void setResponseHeader(String name, String value)
      Add a header to the response.
      Parameters:
      name - name of the header
      value - value of the header
    • getResponseHeader

      Optional<String> getResponseHeader(String name)
      Get a header from the response.
      Parameters:
      name - name of the header
      Returns:
      the value of the header
    • setResponseContentType

      void setResponseContentType(String content)
      Sets the response content type.
      Parameters:
      content - the content type
    • getServerName

      String getServerName()
      Return the server name.
      Returns:
      the server name
    • getServerPort

      int getServerPort()
      Return the server port.
      Returns:
      the server port
    • getScheme

      String getScheme()
      Return the scheme.
      Returns:
      the scheme
    • isSecure

      boolean isSecure()
      Return whether the request is secure.
      Returns:
      whether the request is secure
    • getFullRequestURL

      String getFullRequestURL()
      Return the full URL (with query string) the client used to request the server.
      Returns:
      the URL
      Since:
      1.5.0
    • getRequestURL

      default String getRequestURL()
      Return the full URL (without the query string) the client used to request the server.
      Returns:
      the URL
      Since:
      5.1.2
    • getRequestCookies

      Collection<Cookie> getRequestCookies()
      Retrieves request cookies.
      Returns:
      the request cookies
      Since:
      1.8.0
    • addResponseCookie

      void addResponseCookie(Cookie cookie)
      Adds cookies to the response
      Parameters:
      cookie - a cookie to add to the response
      Since:
      1.8.0
    • getPath

      String getPath()
      Get the "servlet path" (in a JEE style).
      Returns:
      the "servlet path"
      Since:
      1.8.1
    • getRequestContent

      default String getRequestContent()
      Gets content body of the original request.
      Returns:
      the request content
      Since:
      1.9.2
    • getProtocol

      default String getProtocol()
      Get the protocol version.
      Returns:
      the protocol version