Name
ServletResponse
Synopsis
Interface Name: javax.servlet.ServletResponse
Superinterface: None
Immediate Subinterfaces:
javax.servlet.http.HttpServletResponse
Interfaces Implemented: None
Availability: Servlet API 1.0 and later
Description
Servlets use ServletResponse objects to send MIME
encoded data back to the client. The servlet engine creates this
object and passes it to the servlet’s
service() method. To send binary data, use the
ServletOutputStream returned by
getOutputStream(). To send character data, use the
PrintWriter returned by
getWriter(). You can explicitly set the
output’s MIME type using the
setContentType() method. If you elect to set this
manually, do so before calling getWriter(), as
getWriter() consults the content type to determine
which charset to use. Consult RFC 2045 at http://www.ietf.org/rfc/rfc2045.txt for more
information on MIME.
Interface Declaration
public interface ServletResponse {
// Methods
public abstract String getCharacterEncoding(); // New in 2.0
public abstract ServletOutputStream getOutputStream() throws IOException;
public abstract PrintWriter getWriter() throws IOException; // New in 2.0
public abstract void setContentLength(int len);
public abstract void setContentType(String type);
}Methods
getCharacterEncoding()
public abstract String getCharacterEncoding()
- Description
Returns the charset encoding used for this MIME body. This is the charset specified by the assigned content type or
"ISO-8859-1"if no charset has been specified. This method was ...