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. To send binary data, use the ServletOutputStream returned by getOutputStream( ). In order to send character data, use the PrintWriter returned by getWriter( ). You can explicitly set the output’s MIME type using the setContentType( ) method and can set the response locale using the setLocale( ) method. Make these calls before calling getWriter( ), as getWriter( ) consults the content type and locale 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 void flushBuffer() throws IOException; // New in 2.2 public abstract int getBufferSize(); // New in 2.2 public abstract String getCharacterEncoding(); // New in 2.0 public abstract Locale getLocale(); // New in 2.2 public abstract ServletOutputStream getOutputStream() throws IOException, IllegalStateException; public abstract PrintWriter getWriter() // New in 2.0 throws IOException, IllegalStateException; public abstract boolean isCommitted(); // New in 2.2 public abstract void reset() throws IllegalStateException; // New in 2.2 public abstract void setBufferSize(int size) ...

Get Java Servlet Programming, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.