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 #setCharacterEncoding or #setContentType methods, or implicitly using the #setLocale method. Explicit specifications take precedence over implicit specifications. Calls made to these methods after getWriter has been called or after the response has been committed have no effect on the character encoding. If no character encoding has been specified, ISO-8859-1 is returned. See RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) for more information about character encoding and MIME.
a String specifying the name of the character encoding, for example, UTF-8
Returns the content type used for the MIME body sent in this response. The content type proper must have been specified using #setContentType 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 #getCharacterEncoding or #getWriter has been called, the charset parameter is included in the string returned. If no character encoding has been specified, the charset parameter is omitted.
a String specifying the content type, for example, text/html; charset=UTF-8, or null
Servlet 2.4
Gets the 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.
This method considers only response headers set or added via #setHeader, #addHeader, #setDateHeader, #addDateHeader, #setIntHeader, or #addIntHeader, respectively.
the name of the response header whose value to return
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
Servlet 3.0
Gets the names of the headers of this response.
This method considers only response headers set or added via #setHeader, #addHeader, #setDateHeader, #addDateHeader, #setIntHeader, or #addIntHeader, respectively.
Any changes to the returned Collection must not affect this HttpServletResponse.
a (possibly empty) Collection of the names of the headers of this response
Servlet 3.0
Gets the values of the response header with the given name.
This method considers only response headers set or added via #setHeader, #addHeader, #setDateHeader, #addDateHeader, #setIntHeader, or #addIntHeader, respectively.
Any changes to the returned Collection must not affect this HttpServletResponse.
the name of the response header whose values to return
a (possibly empty) Collection of the values of the response header with the given name
Servlet 3.0
Returns a ServletOutputStream suitable for writing binary data in the response. The servlet container does not encode the binary data.
Calling flush() on the ServletOutputStream commits the response.
Either this method or #getWriter may be called to write the body, not both, except when #reset has been called.
a ServletOutputStream for writing binary data
IllegalStateException if the getWriter method has been called on this response
IOException if an input or output exception occurred
Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding returned by #getCharacterEncoding. If the response's character encoding has not been specified as described in getCharacterEncoding (i.e., the method just returns the default value ISO-8859-1), getWriter updates it to ISO-8859-1. Calling flush() on the PrintWriter commits the response. Either this method or #getOutputStream may be called to write the body, not both, except when #reset has been called.
a PrintWriter object that can return character data to the client
java.io.UnsupportedEncodingException if the character encoding returned by getCharacterEncoding cannot be used
IllegalStateException if the getOutputStream method has already been called for this response object
IOException if an input or output exception occurred
Extends the ServletResponse interface to provide HTTP-specific functionality in sending a response. For example, it has methods to access HTTP headers and cookies.
The servlet container creates an HttpServletResponse object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
Author
Various
See
javax.servlet.ServletResponse