Bluestep JS Documentation
    Preparing search index...

    Class Response

    Object used to help with the response data.

    Index

    Constructors

    Methods

    • Adds a response header with the given name and value. This method allows response headers to have multiple values.

      Parameters

      Returns Response

    • Writes a [[Java.ByteArray]] to the response. If there is large amount of data to be written, it is better to use [[binaryStream]].This method will close the stream. Same as B.response.binaryStream(out => out.write(data));

      Parameters

      • data: ByteArray

        the data to write to the response

      Returns void

    • Provides a [[Java.IO.ServletOutputStream]] to the callback function to write to the response. This method will close the stream.

      Parameters

      Returns void

      B.response.binaryStream(out => {
      });
    • Returns the name of the character encoding (MIME charset) used for the body sent in this response. The character encoding may have been specified explicitly using the [[characterEncoding]] or [[contentType]] methods, or may have be set by Bluestep Application. Explicit specifications take precedence over implicit specifications. Calls made to these methods after [[writer]] has been called or after the response has been committed have no effect on the character encoding. If no character encoding has been specified, UTF-8 is returned.

      Returns string

    • Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the character encoding has already been set by [[contentType]] or the Bluestep Application this method overrides it. Calling [[contentType]] with the String of text/html and calling this method with the String of UTF-8 is equivalent with calling [[contentType]] with the String of text/html; charset=UTF-8. This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.

      Containers must communicate the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the character encoding is communicated as part of the Content-Type header for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.

      Parameters

      • charset: string

      Returns Response

    • Returns if the response contains a header by name.

      Parameters

      • data: string

        the header name

      Returns ServletOutputStream

    • Returns the content type used for the MIME body sent in this response. The content type proper must have been specified using [[contentType]] before the response is committed. If no content type has been specified, this method returns null. If a content type has been specified, and a character encoding has been explicitly or implicitly specified as described in [[characterEncoding]] or [[writer]] has been called, the charset parameter is included in the string returned. If no character encoding has been specified, the charset parameter is omitted

      Returns string

    • Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called before writer is called. This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after getWriter has been called or after the response has been committed.

      Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the Content-Type header is used.

      Parameters

      • contentType: string

      Returns Response

    • Sends an error response to the client using the specified status and clears the buffer. The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html". The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter and the msg parameter will be ignored. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

      Parameters

      • sc: number

        the error status code

      • Optionalname: string

        the secriptive messge

      Returns void

    • Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The [[containsHeader]] method can be used to test for the presence of a header before setting its value

      Parameters

      Returns Response

    • Same as calling optHeader().orElse(null)

      Parameters

      • name: string

      Returns string

    • Adds headers in pairs. Must be an even number of arguments.

      Returns Response

      B.response.headers(
      "Cache-Control", "private, must-revalidate, max-age=0"
      "Content-Type", "text/plain; charset=UTF-8"
      );
    • Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written

      Returns boolean

    • Has the response been redirect

      Returns boolean

    • Gets the optional value of the response header with the given name. If a response header with the given name exists and contains multiple values, the value that was added first will be returned.

      Parameters

      • name: string

      Returns Optional<string>

    • Writes an object to the response. If the data is a large object it is better to break up the data and use [[stream]] if possible.This method will try out different things to resolve the data. If the data is null then output null. If the data is a string then output the string. If the data is a [[Java.IO.Reader] then it will transfer it to the output. If the data is an array then it will iterate it's members and output them. If the data is a function it will execute it with no arguments and output the results. If the data is Iterable. It's next() methods will be called and output it's members. Finally the toString() will be called on the data This method will close the stream.

      Parameters

      • data: any

        the data to write to the response

      Returns void

    • Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer. The buffer will be replaced with the data set by this method. Calling this method sets the status code to SC_FOUND 302 (Found). This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to. If a redirect has already been called this method returns false and does not redirect.

      Parameters

      • location: string

        the redirect location URL

      Returns boolean

    • This will remove a response header.

      Parameters

      • key: string

      Returns Response

    • Returns the current status code of this response

      Returns number

    • Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the SC_OK or SC_MOVED_TEMPORARILY status codes)

      Parameters

      • status: number

      Returns Response

    • Provides a [[Java.IO.PrintWriter]] to the callback function to write to the response. This method will close the stream.

      Parameters

      • consumer: (out: PrintWriter) => void

        Function that uses writer

      Returns void

      B.response.stream(out => {
      });
    • Returns the response's [[Java.IO.PrintWriter]].

      Returns PrintWriter