O'Reilly logo

Java Enterprise in a Nutshell, Second Edition by David Flanagan, Jim Farley, William Crawford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required