Interface Client


public interface Client
The Client interface provides information and methods pertaining to the client browser, including access to the request and response objects, methods to create and read cookies, and information on the capabilities of the client browser.
Since:
V4.4
  • Method Summary

    Modifier and Type Method Description
    javax.servlet.http.Cookie addCookie​(java.lang.String cookieName, java.lang.String cookieValue, int age)
    Adds a cookie to the response object.
    void addCookie​(javax.servlet.http.Cookie cookie)
    Adds a cookie to the response object.
    javax.servlet.http.Cookie createCookie​(java.lang.String cookieName, java.lang.String cookieValue, int age)
    Creates a javax.servlet.http.Cookie but does NOT add the cookie to the response object.
    java.lang.String getCookieValue​(java.lang.String cookieName)
    Returns the value of the named cookie or null if the cookie does not exist.
    FormSession getFormSession()
    Returns a FormSession object which represents a single browser window, usually a separate tab within the clilent browser.
    WrappedHttpSession getHttpSession()
    Returns the HttpSession object representing the client browser session.
    int getIEVersion()
    Returns the MS Internet Explorer version.
    javax.servlet.http.HttpServletRequest getRequest()
    Returns the HttpServletRequest object for the user request.
    javax.servlet.http.HttpServletResponse getResponse()
    Returns the HttpServletResponse object used to send a response to the user.
    java.lang.String getUserAgent()
    Returns the user-agent request header.
    java.lang.String getWebappUrlBase()
    Returns a base URL to access the root of the current web application i.e.
    boolean isBackButtonUsed()
    Returns true if the user has clicked the back button immediately prior to the request currently being processed.
    boolean isChrome()
    Returns true when the client browser is Chrome, otherwise returns false.
    boolean isEdge()
    Returns true when the client browser is MS Edge, otherwise returns false.
    boolean isFirefox()
    Returns true when the client browser is Firefox, otherwise returns false.
    boolean isIE()
    Returns true when the client browser is MS Internet Explorer, otherwise returns false.
    boolean isJavascriptUsed()
    Returns true if Javascript is currently being used.
    boolean isMobile()
    Returns true when the client browser is a mobile phone.
    boolean isOpera()
    Returns true when the client browser is Opera, otherwise returns false.
    boolean isSafari()
    Returns true when the client browser is Safari, otherwise returns false.
    boolean isSecure()
    Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
    boolean supportsCookies()
    Returns false if cookies are disabled on the client browser, otherwise returns true.
    boolean supportsJavascript()
    Returns false if Javascript is disabled on the client browser, otherwise returns true.
  • Method Details

    • getRequest

      javax.servlet.http.HttpServletRequest getRequest()
      Returns the HttpServletRequest object for the user request. This can be used to access information such as request parameters, request headers, user's ip address etc.
      Returns:
      request object
      Since:
      V4.4
    • getHttpSession

      WrappedHttpSession getHttpSession()
      Returns the HttpSession object representing the client browser session.

      When there is a need to get/set session attributes, consider using method getFormSession() instead of this method. This gives access to session attributes within a scope limited to just a single browser tab. This, in turn, allows the user to concurrently run the same form in multiple browser tabs without the risk that these might interfere with each other.

      Returns:
      session object
      Since:
      V4.4
      See Also:
      getFormSession()
    • getResponse

      javax.servlet.http.HttpServletResponse getResponse()
      Returns the HttpServletResponse object used to send a response to the user.
      Returns:
      response object
      Since:
      V4.4
    • getCookieValue

      java.lang.String getCookieValue​(java.lang.String cookieName)
      Returns the value of the named cookie or null if the cookie does not exist.
      Returns:
      cookie value
      Since:
      V4.4
    • addCookie

      javax.servlet.http.Cookie addCookie​(java.lang.String cookieName, java.lang.String cookieValue, int age)
      Adds a cookie to the response object. The age parameter specifies the lifetime of the cookie in seconds. A negative value denotes a session cookie i.e. not persisted on the client. A value of 0 deletes the cookie. NB The new cookie's value will not be available to getCookieValue() until the next request.
      Parameters:
      cookieName - the name of the new cookie
      cookieValue - the value of the new cookie
      age - age of the cookie in seconds, see above description
      Returns:
      the added cookie
      Since:
      V4.4
    • createCookie

      javax.servlet.http.Cookie createCookie​(java.lang.String cookieName, java.lang.String cookieValue, int age)
      Creates a javax.servlet.http.Cookie but does NOT add the cookie to the response object. Once the cookie has been added to the response, it is no longer possible to change the cookie. This method should be used in conjunction with addCookie(Cookie)

      The age parameter specifies the lifetime of the cookie in seconds. A negative value denotes a session cookie i.e. not persisted on the client. A value of 0 deletes the cookie. NB The new cookie's value will not be available to getCookieValue() until the next request.

      Javascript example:

       var newCookie = client.createCookie("FullName", "Joe Bloggs", 1000000);
       newCookie.setSecure(true);
       newCookie.setHttpOnly(true);
       client.addCookie(newCookie);
       
      Parameters:
      cookieName - the name of the new cookie
      cookieValue - the value of the new cookie
      age - age of the cookie in seconds, see above description
      Returns:
      the created cookie
      Since:
      V5.10
      See Also:
      addCookie(Cookie)
    • addCookie

      void addCookie​(javax.servlet.http.Cookie cookie)
      Adds a cookie to the response object. This method should be used in conjunction with createCookie(String, String, int) NB The new cookie's value will not be available to getCookieValue() until the next request.
      Parameters:
      cookie -
      Since:
      V5.10
      See Also:
      createCookie(String, String, int)
    • getUserAgent

      java.lang.String getUserAgent()
      Returns the user-agent request header. This contains a description of the browser type.
      Returns:
      user-agent request header
      Since:
      V4.4
    • supportsCookies

      boolean supportsCookies()
      Returns false if cookies are disabled on the client browser, otherwise returns true.
      Since:
      V4.4
    • supportsJavascript

      boolean supportsJavascript()
      Returns false if Javascript is disabled on the client browser, otherwise returns true. Note that Javascript may not be used even though this is supported by the browser, as Javascript can be disabled using system preferences. To check whether Javascript is being used, use method isJavascriptUsed().
      Since:
      V4.4
    • isFirefox

      boolean isFirefox()
      Returns true when the client browser is Firefox, otherwise returns false.
      Since:
      V4.4
    • isEdge

      boolean isEdge()
      Returns true when the client browser is MS Edge, otherwise returns false.
      Since:
      V5.4
    • isIE

      boolean isIE()
      Returns true when the client browser is MS Internet Explorer, otherwise returns false.
      Since:
      V4.4
    • isChrome

      boolean isChrome()
      Returns true when the client browser is Chrome, otherwise returns false.
      Since:
      V4.4
    • isOpera

      boolean isOpera()
      Returns true when the client browser is Opera, otherwise returns false.
      Since:
      V4.4
    • isSafari

      boolean isSafari()
      Returns true when the client browser is Safari, otherwise returns false.
      Since:
      V4.4
    • getIEVersion

      int getIEVersion()
      Returns the MS Internet Explorer version.
      Since:
      V4.4
    • isMobile

      boolean isMobile()
      Returns true when the client browser is a mobile phone.
      Since:
      V4.4
    • isBackButtonUsed

      boolean isBackButtonUsed()
      Returns true if the user has clicked the back button immediately prior to the request currently being processed. Note that when true, any back button event specified at form level will be executed.
      Since:
      V4.4
    • isJavascriptUsed

      boolean isJavascriptUsed()
      Returns true if Javascript is currently being used. Returns false if either Javascript is disabled on the client, or Javascript is disabled on the Ebase server using system preferences.
      Since:
      V4.4
      See Also:
      supportsJavascript(), SystemPreferences.isUseJavascript()
    • isSecure

      boolean isSecure()
      Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
      Since:
      V4.4
    • getFormSession

      FormSession getFormSession()
      Returns a FormSession object which represents a single browser window, usually a separate tab within the clilent browser. The form session object gives access to form session attributes, which exist for the duration of the HTTP session, but are limited in scope to just a single form session - usually a browser tab.
      Since:
      V4.4
      See Also:
      getHttpSession()
    • getWebappUrlBase

      java.lang.String getWebappUrlBase()
      Returns a base URL to access the root of the current web application i.e. returns a URL of the type: scheme://host:port/webapp e.g. https://mydomain.com:80/ebase
      Since:
      V5.2