Response Generation

A request generally warrants a response, and servlets are no exception in this regard.

Servlets make use of ServletResponse to simplify this common task. The ServletResponse object, commonly referred to as the response object, is in fact provided to a servlet alongside the request object as a parameter to the service method.

Output can be written in either binary or character format by obtaining a handle to either a ServletOutputStream object or a PrintWriter object, respectively. Some of the other methods provided by the ServletResponse interface are contained in the following list:

  • getOutputStream obtains the handle to a ServletOutputStream object for binary data.

  • getWriter obtains the handle to a PrintWriter object for character ...

Get Developing Enterprise Java Applications with J2EE™ and UML 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.