Interface IInterceptorResponse

All Known Implementing Classes:
ServerServicesInterceptorResponseWrapper

public interface IInterceptorResponse
The IInterceptorResponse interface defines a contract for manipulating HTTP response data in an interceptor context. It provides methods for setting status codes, headers, content type, character encoding, and writing response data, as well as managing the response buffer and state.

Implementations of this interface allow interceptors to inspect, modify, and control HTTP responses in a framework-agnostic manner.

Typical usage includes:

  • Setting response status codes and headers
  • Writing binary or character data to the response
  • Managing response buffer and commit state
  • Setting content type and character encoding
  • Sending error responses to the client
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addHeader(String name, String value)
    Adds a response header with the given name and value.
    void
    Forces any content in the buffer to be written to the client.
    int
    Returns the actual buffer size used for the response
    Returns the name of the character encoding
    Returns a String that indicates the content-type of the response
    Returns the value of the specified request header as a String
    Gets the names of the headers of this response.
    Gets the values of the response header with the given name.
    jakarta.servlet.ServletOutputStream
    Returns a ServletOutputStream suitable for writing binary data in the response.
    int
    Returns the current status code of this response.
    Returns a PrintWriter object that can send character text to the client.
    boolean
    Returns a boolean indicating if the response has been committed.
    void
    Clears the content of the underlying buffer in the response without clearing headers or status code.
    void
    sendError(int sc)
    Sends an error response to the client using the specified status code and clears the buffer.
    void
    sendError(int sc, String msg)
    Sends an error response to the client using the specified status code and clears the buffer.
    void
    Sets the length of the content body in the response
    void
    Sets the length of the content body in the response
    void
    setHeader(String name, String value)
    Sets a response header with the given name and value.
    void
    setStatus(int sc)
    Sets the status code for this response.
  • Method Details

    • sendError

      void sendError(int sc, String msg) throws IOException
      Sends an error response to the client using the specified status code and clears the buffer.
      Parameters:
      sc - - the error status code
      msg - - the descriptive message
      Throws:
      IOException - If an input or output exception occurs
    • sendError

      void sendError(int sc) throws IOException
      Sends an error response to the client using the specified status code and clears the buffer.
      Parameters:
      sc - - the error status code
      Throws:
      IOException - If an input or output exception occurs
    • setStatus

      void setStatus(int sc)
      Sets the status code for this response.
      Parameters:
      sc - - the status code
    • getStatus

      int getStatus()
      Returns the current status code of this response.
      Returns:
      the current status code of this response
    • getHeader

      String getHeader(String name)
      Returns the value of the specified request header as a String
      Parameters:
      name - - the name of the response header whose value to return
      Returns:
      the value of the response header with the given name, or null if no header with the given name has been set on this response
    • getHeaders

      Collection<String> getHeaders(String name)
      Gets the values of the response header with the given name.
      Parameters:
      name - - the name of the response header whose values to return
      Returns:
      a Collection of the values of the response header with the given name
    • getHeaderNames

      Collection<String> getHeaderNames()
      Gets the names of the headers of this response.
      Returns:
      a Collection of the names of the headers of this response
    • setHeader

      void setHeader(String name, String value)
      Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one.
      Parameters:
      name - - the name of the header
      value - - the header value
    • addHeader

      void addHeader(String name, String value)
      Adds a response header with the given name and value.
      Parameters:
      name - - the name of the header
      value - - the additional header value
    • getOutputStream

      jakarta.servlet.ServletOutputStream getOutputStream() throws IOException
      Returns a ServletOutputStream suitable for writing binary data in the response.
      Returns:
      a ServletOutputStream for writing binary data
      Throws:
      IOException - if the getWriter method has been called on this response
    • getWriter

      PrintWriter getWriter() throws IOException
      Returns a PrintWriter object that can send character text to the client.
      Returns:
      a PrintWriter object that can return character data to the client
      Throws:
      IOException - if an input or output exception occurred
    • flushBuffer

      void flushBuffer() throws IOException
      Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written.
      Throws:
      IOException
    • resetBuffer

      void resetBuffer()
      Clears the content of the underlying buffer in the response without clearing headers or status code.
    • getCharacterEncoding

      String getCharacterEncoding()
      Returns the name of the character encoding
    • isCommitted

      boolean isCommitted()
      Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.
      Returns:
      a boolean indicating if the response has been committed
    • getContentType

      String getContentType()
      Returns a String that indicates the content-type of the response
      Returns:
      String that indicates the content-type of the response
    • setContentLength

      void setContentLength(int len)
      Sets the length of the content body in the response
      Parameters:
      len - - an int specifying the length of the content being returned to the client; sets the Content-Length header
    • setContentLengthLong

      void setContentLengthLong(long len)
      Sets the length of the content body in the response
      Parameters:
      len - - a long specifying the length of the content being returned to the client; sets the Content-Length header
    • getBufferSize

      int getBufferSize()
      Returns the actual buffer size used for the response
      Returns:
      an int specifying the actual buffer size used for the response