2 Minutes To Code (β Version)

Java Servlets - 2 minute tutorial

How to set content type and content length headers

To set the content encoding, content type and content length of the http response, you need to use the methods setCharacterEncoding(..), setContentLength(..) and setContentType(..) of the HttpServletResponse object.

These methods are essentially convenience methods for setting the corresponding headers Content-Encoding, Content-Length & Content-Type.