O'Reilly logo

Java Servlet Programming, 2nd Edition by William Crawford, Jason Hunter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required