home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / binaries / Windows / jsdk / src / javax / servlet / http / HttpServletResponse.java < prev    next >
Encoding:
Java Source  |  1997-07-18  |  7.1 KB  |  219 lines

  1. /*
  2.  * @(#)HttpServletResponse.java    1.15 97/05/22
  3.  * 
  4.  * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.0
  20.  */
  21.  
  22. package javax.servlet.http;
  23.  
  24. import javax.servlet.ServletResponse;
  25. import java.io.IOException;
  26.  
  27. /**
  28.  * This interface, implemented by network service developers,
  29.  * represents an HTTP servlet response.  It allows a servlet's service
  30.  * method to manipulate HTTP-protocol specified header information, and
  31.  * return data to its client.
  32.  *
  33.  * @version    1.15, 05/22/97
  34.  * @author David Connelly
  35. */
  36. public
  37. interface HttpServletResponse extends ServletResponse {
  38.     /**
  39.      * Returns true if the response message header has a field with
  40.      * the specified name.
  41.      * @param name the header field name
  42.      */
  43.     public boolean containsHeader(String name);
  44.  
  45.     /**
  46.      * Sets the status code and message for this response.
  47.      * @param sc the status code
  48.      * @param sm the status message
  49.      */
  50.     public void setStatus(int sc, String sm);
  51.  
  52.     /**
  53.      * Sets the status code and a default message for this response.
  54.      * @param sc the status code
  55.      */
  56.     public void setStatus(int sc);
  57.  
  58.     /**
  59.      * 
  60.      * Adds a field to the response header with a given name and
  61.      * value.  If the field had already been set, the new value
  62.      * overwrites the previous one.  The containsHeader method can be
  63.      * used to test for the presence of a header before setting its
  64.      * value.
  65.      * 
  66.      * @param name the header field name
  67.      * @param value the header field value */
  68.     public void setHeader(String name, String value);
  69.  
  70.     /**
  71.      *
  72.      * Adds a field to the response header with a given name and
  73.      * integer value.  If the field had already been set, the new
  74.      * value overwrites the previous one.  The containsHeader method
  75.      * can be used to test for the presence of a header before setting
  76.      * its value.
  77.      *
  78.      * @param name the header field name
  79.      * @param value the header field integer value */
  80.     public void setIntHeader(String name, int value);
  81.  
  82.     /**
  83.      * 
  84.      * Adds a field to the response header with a given name and
  85.      * date-valued field.  The date is specified in terms of
  86.      * milliseconds since the epoch.  If the date field had already
  87.      * been set, the new value overwrites the previous one.  The
  88.      * containsHeader method can be used to test for the presence of a
  89.      * header before setting its value.
  90.      * 
  91.      * @param name the header field name
  92.      * @param value the header field date value */
  93.     public void setDateHeader(String name, long date);
  94.  
  95.     /**
  96.      * Sends an error response to the client using the specified status
  97.      * code and descriptive message.
  98.      * @param sc the status code
  99.      * @param msg the detail message
  100.      * @exception IOException If an I/O error has occurred.
  101.      */
  102.     public void sendError(int sc, String msg) throws IOException;
  103.  
  104.     /**
  105.      * Sends an error response to the client using the specified
  106.      * status code and a default message.
  107.      * @param sc the status code
  108.      * @exception IOException If an I/O error has occurred.
  109.      */
  110.     public void sendError(int sc) throws IOException;
  111.  
  112.     /**
  113.      * Sends a redirect response to the client using the specified
  114.      * redirect location URL.  The URL must be absolute (e.g.,
  115.      * <code><em>https://hostname/path/file.html</em></code>).
  116.      * Relative URLs are not permitted here.
  117.      *
  118.      * @param location the redirect location URL
  119.      * @exception IOException If an I/O error has occurred.
  120.      */
  121.     public void sendRedirect(String location) throws IOException;
  122.  
  123.     /*
  124.      * Server status codes; see RFC 1945.
  125.      */
  126.  
  127.     /**
  128.      * Status code (200) indicating the request succeeded normally.
  129.      */
  130.     public static final int SC_OK = 200;
  131.  
  132.     /**
  133.      * Status code (201) indicating the request succeeded and created
  134.      * a new resource on the server.
  135.      */
  136.     public static final int SC_CREATED = 201;
  137.  
  138.     /**
  139.      * Status code (202) indicating that a request was accepted for
  140.      * processing, but was not completed.
  141.      */
  142.     public static final int SC_ACCEPTED = 202;
  143.  
  144.     /**
  145.      * Status code (204) indicating that the request succeeded but that
  146.      * there was no new information to return.
  147.      */
  148.     public static final int SC_NO_CONTENT = 204;
  149.  
  150.     /**
  151.      * Status code (301) indicating that the resource has permanently
  152.      * moved to a new location, and that future references should use a
  153.      * new URI with their requests.
  154.      */
  155.     public static final int SC_MOVED_PERMANENTLY = 301;
  156.  
  157.     /**
  158.      * Status code (302) indicating that the resource has temporarily
  159.      * moved to another location, but that future references should
  160.      * still use the original URI to access the resource.
  161.      */
  162.     public static final int SC_MOVED_TEMPORARILY = 302;
  163.  
  164.     /**
  165.      * Status code (304) indicating that a conditional GET operation
  166.      * found that the resource was available and not modified.
  167.      */
  168.     public static final int SC_NOT_MODIFIED = 304;
  169.  
  170.     /**
  171.      * Status code (400) indicating the request sent by the client was
  172.      * syntactically incorrect.
  173.      */
  174.     public static final int SC_BAD_REQUEST = 400;
  175.  
  176.     /**
  177.      * Status code (401) indicating that the request requires HTTP
  178.      * authentication.
  179.      */
  180.     public static final int SC_UNAUTHORIZED = 401;
  181.  
  182.     /**
  183.      * Status code (403) indicating the server understood the request
  184.      * but refused to fulfill it.
  185.      */
  186.     public static final int SC_FORBIDDEN = 403;
  187.  
  188.     /**
  189.      * Status code (404) indicating that the requested resource is not
  190.      * available.
  191.      */
  192.     public static final int SC_NOT_FOUND = 404;
  193.  
  194.     /**
  195.      * Status code (500) indicating an error inside the HTTP service
  196.      * which prevented it from fulfilling the request.
  197.      */
  198.     public static final int SC_INTERNAL_SERVER_ERROR = 500;
  199.  
  200.     /**
  201.      * Status code (501) indicating the HTTP service does not support
  202.      * the functionality needed to fulfill the request.
  203.      */
  204.     public static final int SC_NOT_IMPLEMENTED = 501;
  205.  
  206.     /**
  207.      * Status code (502) indicating that the HTTP server received an
  208.      * invalid response from a server it consulted when acting as a
  209.      * proxy or gateway.
  210.      */
  211.     public static final int SC_BAD_GATEWAY = 502;
  212.  
  213.     /**
  214.      * Status code (503) indicating that the HTTP service is
  215.      * temporarily overloaded, and unable to handle the request.
  216.      */
  217.     public static final int SC_SERVICE_UNAVAILABLE = 503;
  218. }
  219.