Class HttpResponseFacade

java.lang.Object
org.eclipse.dirigible.api.v3.http.HttpResponseFacade
All Implemented Interfaces:
IScriptingFacade

public class HttpResponseFacade
extends Object
implements IScriptingFacade
Java facade for working HttpServletResponse
  • Constructor Details

  • Method Details

    • getResponse

      public static final javax.servlet.http.HttpServletResponse getResponse()
      Returns the HttpServletResponse associated with the current thread context
      Returns:
      the response
    • isValid

      public static final boolean isValid()
      Checks if there is a HttpServletResponse associated with the current thread context
      Returns:
      true, if there is a HttpServletResponse associated with the current thread context
    • print

      public static final void print​(String text)
      Prints the text
      Parameters:
      text - the text
    • print

      public static final void print​(Object o)
      Prints the object as text
      Parameters:
      o - the object to be printed
    • print

      public static final void print​(int i)
      Prints the int primitive as text
      Parameters:
      i - the integer to be printed
    • print

      public static final void print​(double d)
      Prints the double primitive as text
      Parameters:
      d - the double to be printed
    • print

      public static final void print​(Integer i)
      Prints the integer as text
      Parameters:
      i - the integer to be printed
    • print

      public static final void print​(Double d)
      Prints the double as text
      Parameters:
      d - the double to be printed
    • println

      public static final void println​(String text)
      Prints the text with a carriage return
      Parameters:
      text - the text
    • println

      public static final void println​(Object o)
      Prints the object as text with a carriage return
      Parameters:
      o - the object
    • println

      public static final void println​(int i)
      Prints the int primitive as text with a carriage return
      Parameters:
      i - the int primitive
    • println

      public static final void println​(double d)
      Prints the double primitive as text with a carriage return
      Parameters:
      d - the double primitive
    • println

      public static final void println​(Integer i)
      Prints the Integer as text with a carriage return
      Parameters:
      i - the integer
    • println

      public static final void println​(Double d)
      Prints the Double as text with a carriage return
      Parameters:
      d - the double
    • write

      public static final void write​(byte[] bytes)
      Writes the bytes to the output stream
      Parameters:
      bytes - the bytes
    • write

      public static final void write​(String input)
      Writes the string bytes to the output stream
      Parameters:
      input - the input
    • isCommitted

      public static boolean isCommitted()
      Checks if the response is committed.
      Returns:
      true, if is committed
    • setContentType

      public static final void setContentType​(String contentType)
      Sets the content type.
      Parameters:
      contentType - the new content type
    • flush

      public static final void flush()
      Flushes the response
    • close

      public static final void close()
      Closes the response output stream
    • addCookie

      public static final void addCookie​(String cookieJson)
      Adds a cookie
      Parameters:
      cookieJson - the cookie in JSON format
    • containsHeader

      public static final boolean containsHeader​(String name)
      Checks if the response contains a header with the specified name
      Parameters:
      name - the name
      Returns:
      true, if the header has already been added
    • encodeURL

      public static final String encodeURL​(String url)
      Encodes the specified URL
      Parameters:
      url - the url
      Returns:
      the URL encoded
    • getCharacterEncoding

      public static final String getCharacterEncoding()
      Returns the character encoding.
      Returns:
      the character encoding
    • encodeRedirectURL

      public static final String encodeRedirectURL​(String url)
      Encode redirect URL.
      Parameters:
      url - the url
      Returns:
      the string
    • getContentType

      public static final String getContentType()
      Returns the content type.
      Returns:
      the content type
    • sendError

      public static final void sendError​(int sc, String msg) throws IOException
      Sends and error.
      Parameters:
      sc - the sc
      msg - the msg
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • sendError

      public static final void sendError​(Double sc, String msg) throws IOException
      Sends error.
      Parameters:
      sc - the sc
      msg - the msg
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • sendError

      public static final void sendError​(int sc) throws IOException
      Sends error.
      Parameters:
      sc - the sc
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • sendError

      public static final void sendError​(Double sc) throws IOException
      Sends error.
      Parameters:
      sc - the sc
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • setCharacterEncoding

      public static final void setCharacterEncoding​(String charset)
      Sets the character encoding.
      Parameters:
      charset - the new character encoding
    • sendRedirect

      public static final void sendRedirect​(String location) throws IOException
      Sends redirect.
      Parameters:
      location - the location
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • setContentLength

      public static final void setContentLength​(int len)
      Sets the content length.
      Parameters:
      len - the new content length
    • setContentLength

      public static final void setContentLength​(Double len)
      Sets the content length.
      Parameters:
      len - the new content length
    • setHeader

      public static final void setHeader​(String name, String value)
      Sets the header.
      Parameters:
      name - the name
      value - the value
    • addHeader

      public static final void addHeader​(String name, String value)
      Adds the header.
      Parameters:
      name - the name
      value - the value
    • setStatus

      public static final void setStatus​(int sc)
      Sets the status.
      Parameters:
      sc - the new status
    • setStatus

      public static final void setStatus​(Double sc)
      Sets the status.
      Parameters:
      sc - the new status
    • reset

      public static final void reset()
      Reset the buffer
    • getHeader

      public static final String getHeader​(String name)
      Returns the value of the header with the specified name
      Parameters:
      name - the name
      Returns:
      the header
    • setLocale

      public static final void setLocale​(String language)
      Sets the locale.
      Parameters:
      language - the new locale
    • setLocale

      public static final void setLocale​(String language, String country)
      Sets the locale.
      Parameters:
      language - the language
      country - the country
    • setLocale

      public static final void setLocale​(String language, String country, String variant)
      Sets the locale.
      Parameters:
      language - the language
      country - the country
      variant - the variant
    • getHeaders

      public static final String getHeaders​(String name)
      Returns the headers.
      Parameters:
      name - the name
      Returns:
      the headers
    • getHeaderNames

      public static final String getHeaderNames()
      Returns the header names.
      Returns:
      the header names
    • getLocale

      public static final String getLocale()
      Returns the locale.
      Returns:
      the locale
    • getOutputStream

      public static final OutputStream getOutputStream() throws IOException
      Open the output stream of the current servlet response
      Returns:
      the created output stream
      Throws:
      IOException - in case of failure in underlying layer