Name

HttpServletResponse

Synopsis

HttpServletResponse extends javax.servlet.ServletResponse and provides additional methods for HTTP-specific actions and a set of HTTP response code constants. The containsHeader(), setHeader(), setDateHeader(), and setIntHeader() methods allow servlets to set and update specific HTTP response headers. The addCookie() method writes a cookie, represented by a Cookie object, to the client. The sendError() and setStatus() methods allow servlets to set specific HTTP result codes, along with an optional customized error message. The encodeUrl() and encodeRedirectUrl() methods (deprecated in 2.1 in favor of encodeURL() and encodeRedirectURL()) methods support session tracking without the use of cookies. The sendRedirect() method handles an HTTP page redirect.

                  
public interface HttpServletResponse extends ServletResponse {
// Public Constants
   public static final int SC_ACCEPTED;                          // =202
   public static final int SC_BAD_GATEWAY;                       // =502
   public static final int SC_BAD_REQUEST;                       // =400
   public static final int SC_CONFLICT;                          // =409
   public static final int SC_CONTINUE;                          // =100
   public static final int SC_CREATED;                           // =201
   public static final int SC_EXPECTATION_FAILED;                // =417, 2.2
   public static final int SC_FORBIDDEN;                         // =403
   public static final int SC_GATEWAY_TIMEOUT;                   // =504
   public static final int SC_GONE;                              // =410
   public static final int SC_HTTP_VERSION_NOT_SUPPORTED ...

Get Java Enterprise in a Nutshell, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.