10.8. ServletResponse and HttpResponse

For servlets, the ServletResponse and its subclass HttpResponse are two of the most vital classes. These classes perform the function of sending the MIME-encoded data back to the client. Without this, there would be no servlets at all. This class supports both writers (for communicating text-based characters) and output streams (for sending back binary data), as well as enabling the setting of content length and type parameters.

The HttpResponse class adds extra functionality in that it allows the developer to set the HTTP status codes, add cookies and headers, and encode session IDs into URLs. For the moment, we'll leave these advanced topics for Section 10.12, but it is important to be aware of the versatility ...

Get Java™ Network Programming and Distributed Computing 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.