Skip to Main Content
Java Servlet Programming, 2nd Edition
book

Java Servlet Programming, 2nd Edition

by Jason Hunter, William Crawford
April 2001
Intermediate to advanced content levelIntermediate to advanced
780 pages
23h 48m
English
O'Reilly Media, Inc.
Content preview from Java Servlet Programming, 2nd Edition

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) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Servlet Programming

Java Servlet Programming

Jason Hunter

Publisher Resources

ISBN: 0596000405Supplemental ContentErrata Page