home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 September / PCWorld_2000-09_cd.bin / Komunik / sambar / _setup.1 / javaeng.jar / javax / servlet / ServletResponse.java < prev    next >
Text File  |  2000-04-03  |  4KB  |  145 lines

  1. /*
  2.  * ServletResponse.java -- Class used to store servlet response
  3.  *
  4.  * Copyright (c) 1998, 1999 by Free Software Foundation, Inc.
  5.  * Written by Paul Siegmann (pauls@euronet.nl)
  6.  *
  7.  * This program is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU Library General Public License as published
  9.  * by the Free Software Foundation, version 2. (see COPYING.LIB)
  10.  *
  11.  * This program is distributed in the hope that it will be useful, but
  12.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software Foundation
  18.  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
  19.  */
  20.  
  21. package javax.servlet;
  22.  
  23. import java.io.IOException;
  24. import java.io.PrintWriter;
  25.  
  26.  
  27. /**
  28.  * A servlet can use this class to pass information to the client.
  29.  *
  30. #ifdef SERVLET_2_0
  31.  * @version Servlet API 2.0 
  32. #endif
  33. #ifdef SERVLET_2_1
  34.  * @version Servlet API 2.1
  35. #endif
  36. #ifdef SERVLET_2_2
  37.  * @version Servlet API 2.2
  38. #endif
  39.  * @since Servlet API 1.0
  40.  * @author Paul Siegmann (pauls@euronet.nl)
  41.  */
  42. public interface ServletResponse
  43. {
  44.     /**
  45.      * Tells the client how many bytes to expect.
  46.      *
  47.      * @since Servlet API 1.0
  48.      *
  49.      * @param length the number of bytes in the reply
  50.      */
  51.     void setContentLength(int length);
  52.     
  53.     /**
  54.      * Tells the client what mime type to expect
  55.      *
  56.      * @since Servlet API 1.0
  57.      *
  58.      * @param type the mime type of the content
  59.      */
  60.     void setContentType(String type);
  61.  
  62.  
  63.     /**
  64.      * Creates a ServletOutputStream for the servlet to write the data to.
  65.      * <code>setContentLength</code> and <code>setContentType</code> can
  66.      * only be called before anything is written to this stream.
  67.      * It is only possible to call <code>getWriter</code> or
  68.      * <code>getOutputStream</code> on a response, but not both.
  69.      *
  70.      * @since Servlet API 1.0
  71.      *
  72.      * @return ServletOutputStream to write binary data
  73.      * @exception IOException if a i/o exception occurs
  74.      * @exception IllegalStateException if <code>getWriter</code> was already
  75.      * called on this response
  76.      */
  77.     ServletOutputStream getOutputStream() throws IOException;
  78.  
  79.  
  80.     /**
  81.      * Creates a PrintWriter for the servlet to print text to.
  82.      * The contenttype must be set before calling this method.
  83.      * It is only possible to call <code>getWriter</code> or
  84.      * <code>getOutputStream</code> on a response, but not both.
  85.      *
  86.      * @since Servlet API 2.0
  87.      *
  88.      * @return the created PrintWriter
  89.      * @exception IOException if a i/o exception occurs
  90.      * @exception IllegalStateException if <code>getOutputStream</code> was
  91.      * already called on this response
  92.      * @exception java.io.UnsupportedEncodingException if no suitable character
  93.      * encoding can be used
  94.      */
  95.     PrintWriter getWriter() throws IOException;
  96.  
  97.  
  98.  
  99.     /**
  100.      * Returns the characterset encoding in use by this Response
  101.      *
  102.      * @since Servlet API 2.0
  103.      * @return the characterset encoding
  104.      */
  105.     String getCharacterEncoding();
  106.  
  107. #ifdef SERVLET_2_2
  108.  
  109.     /**
  110.      * XXX
  111.      */
  112.     int setBufferSize(int size);
  113.  
  114.  
  115.     /**
  116.      * XXX
  117.      */
  118.     int getBufferSize(void);
  119.  
  120.  
  121.     /**
  122.      * XXX
  123.      */
  124.     void clearBuffer();
  125.  
  126.  
  127.     /**
  128.      * XXX
  129.      */
  130.     boolean isCommitted();
  131.  
  132.  
  133.     /**
  134.      * XXX
  135.      */
  136.     void flushBuffer();
  137.  
  138.  
  139.     /**
  140.      * XXX
  141.      */
  142.     void setLocale();
  143. #endif
  144. }
  145.