<HTML>
<HEAD>
<TITLE>Servlet::ServletResponse - servlet response interface</TITLE>
<LINK REL="stylesheet" HREF="../../libservlet.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:feedback@suse.de">
</HEAD>

<BODY>

<A NAME="__index__"></A>
<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#name">NAME</A></LI>
	<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
	<LI><A HREF="#description">DESCRIPTION</A></LI>
	<LI><A HREF="#methods">METHODS</A></LI>
	<LI><A HREF="#see also">SEE ALSO</A></LI>
	<LI><A HREF="#author">AUTHOR</A></LI>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="name">NAME</A></H1>
<P>Servlet::ServletResponse - servlet response interface</P>
<P>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
  $response-&gt;flushBuffer();</PRE>
<PRE>
  my $size = $response-&gt;getBufferSize();</PRE>
<PRE>
  my $encoding = $response-&gt;getCharacterEncoding();</PRE>
<PRE>
  my $locale = $response-&gt;getLocale();</PRE>
<PRE>
  my $output = $response-&gt;getOutputHandle();</PRE>
<PRE>
  my $writer = $response-&gt;getWriter();</PRE>
<PRE>
  my $flag = $response-&gt;isCommitted();</PRE>
<PRE>
  $response-&gt;reset();</PRE>
<PRE>
  $response-&gt;resetBuffer();</PRE>
<PRE>
  $response-&gt;setBufferSize($size);</PRE>
<PRE>
  $response-&gt;setContentLength($length);</PRE>
<PRE>
  $response-&gt;setContentType($type);</PRE>
<PRE>
  $response-&gt;setLocale($locale);</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>This interface defines an object that assists a servlet in sending a
response to the client. The servlet container creates the object and
passes it as an argument to the servlet's <CODE>service()</CODE> method.</P>
<P>
<HR>
<H1><A NAME="methods">METHODS</A></H1>
<DL>
<DT><STRONG><A NAME="item_flushBuffer"><CODE>flushBuffer()</CODE></A></STRONG><BR>
<DD>
Forces any content in the buffer to be written to the client. A call
to this method automatically commits the resopnse, meaning the status
code and headers will be written.
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_Servlet%3A%3AUtil%3A%3AIOException"><STRONG>Servlet::Util::IOException</STRONG></A></STRONG><BR>
<DD>
</DL>
<DT><STRONG><A NAME="item_getBufferSize"><CODE>getBufferSize()</CODE></A></STRONG><BR>
<DD>
Returns the actual buffer size used for the response, or 0 if no
buffering is used.
<P></P>
<DT><STRONG><A NAME="item_getCharacterEncoding"><CODE>getCharacterEncoding()</CODE></A></STRONG><BR>
<DD>
Returns the name of the character encoding used in the body of this
response. If not charset has been assigned, it is implicitly set to
<EM>ISO-8859-1</EM>.
<P></P>
<DT><STRONG><A NAME="item_getLocale"><CODE>getLocale()</CODE></A></STRONG><BR>
<DD>
Returns the locale assigned to the response.
<P></P>
<DT><STRONG><A NAME="item_getOutputHandle"><CODE>getOutputHandle()</CODE></A></STRONG><BR>
<DD>
Returns a <STRONG>IO::Handle</STRONG> suitable for writing binary data in the
response. The servlet container does not encode the binary data.
<P>Calling <CODE>flush()</CODE> commits the response.</P>
<P>Either this method or <A HREF="#item_getWriter"><CODE>getWriter()</CODE></A> may be called to write the body,
not both.</P>
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_Servlet%3A%3AUtil%3A%3AIllegalStateException"><STRONG>Servlet::Util::IllegalStateException</STRONG></A></STRONG><BR>
<DD>
if the <A HREF="#item_getWriter"><CODE>getWriter()</CODE></A> method has already been called for this response
<P></P>
<DT><STRONG><STRONG>Servlet::Util::IOException</STRONG></STRONG><BR>
<DD>
if an input or output exception occurred
<P></P></DL>
<DT><STRONG><A NAME="item_getWriter"><CODE>getWriter()</CODE></A></STRONG><BR>
<DD>
Returns a <STRONG>XXX</STRONG> object that can send character text to the
client. The character encoding used is the one specified in the
<EM>charset</EM> parameter of <A HREF="#item_setContentType"><CODE>setContentType()</CODE></A>, which must be called
before calling this metod for the charset to take effect.
<P>If necessary, the content type of the response is modified to reflect
the character encoding used.</P>
<P>Calling <CODE>flush()</CODE> commits the response.</P>
<P>Either this method or <A HREF="#item_getOutputHandle"><CODE>getOutputHandle()</CODE></A> may be called to write the
body, not both.</P>
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_Servlet%3A%3AUtil%3A%3AUnsupportedEncodingExceptio"><STRONG>Servlet::Util::UnsupportedEncodingException</STRONG></A></STRONG><BR>
<DD>
if the charset specified in <A HREF="#item_setContentType"><CODE>setContentType()</CODE></A> cannot be used
<P></P>
<DT><STRONG><STRONG>Servlet::Util::IllegalStateException</STRONG></STRONG><BR>
<DD>
if the <A HREF="#item_getOutputHandle"><CODE>getOutputHandle()</CODE></A> method has already been called for this
request
<P></P>
<DT><STRONG><STRONG>Servlet::Util::IOException</STRONG></STRONG><BR>
<DD>
if an input or output exception occurred
<P></P></DL>
<DT><STRONG><A NAME="item_isCommitted"><CODE>isCommitted()</CODE></A></STRONG><BR>
<DD>
Returns a boolean indicating if the response has been committed. A
committed response has already had its status code and headers
written.
<P></P>
<DT><STRONG><A NAME="item_reset"><CODE>reset()</CODE></A></STRONG><BR>
<DD>
Clears any data that exists in the buuffer as well as the status code
and headers.
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><STRONG>Servlet::Util::IllegalStateException</STRONG></STRONG><BR>
<DD>
if the response has already been committed
<P></P></DL>
<DT><STRONG><A NAME="item_resetBuffer"><CODE>resetBuffer()</CODE></A></STRONG><BR>
<DD>
Clears the content of the underlying buffer in the response without
clearing headers or status code.
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><STRONG>Servlet::Util::IllegalStateException</STRONG></STRONG><BR>
<DD>
if the response has already been committed
<P></P></DL>
<DT><STRONG><A NAME="item_setBufferSize"><CODE>setBufferSize($size)</CODE></A></STRONG><BR>
<DD>
Sets the preferred buffer size for the body of the response. The
servlet container will use a buffer at least as large as the size
requested. The actual buffer size can be found using
<A HREF="#item_getBufferSize"><CODE>getBufferSize()</CODE></A>.
<P>A larger buffer allows more content to be written before anything is
actually sent, thus providing the servlet with more time to set
appropriate status codes and headers. A smaller buffer decreases
server memory load and allows the client to start receiving data more
quickly.</P>
<P>This method must be called before any response body content is written.</P>
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24size"><EM>$size</EM></A></STRONG><BR>
<DD>
The preferred buffer size
<P></P></DL>
<P><STRONG>Throws:</STRONG></P>
<DL>
<DT><STRONG><STRONG>Servlet::Util::IllegalStateException</STRONG></STRONG><BR>
<DD>
if content has been written to the buffer
<P></P></DL>
<DT><STRONG><A NAME="item_setContentLength"><CODE>setContentLength($len)</CODE></A></STRONG><BR>
<DD>
Sets the length of the content body in the response. In HTTP servlets,
this method sets the HTTP <EM>Content-Length</EM> header.
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24len"><EM>$len</EM></A></STRONG><BR>
<DD>
The length of the content being returned to the client
<P></P></DL>
<DT><STRONG><CODE>setContentLength($len)</CODE></STRONG><BR>
<DD>
Sets the length of the content body in the response. In HTTP servlets,
this method sets the HTTP <EM>Content-Length</EM> header.
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><EM>$len</EM></STRONG><BR>
<DD>
The length of the content being returned to the client
<P></P></DL>
<DT><STRONG><A NAME="item_setContentType"><CODE>setContentType($type)</CODE></A></STRONG><BR>
<DD>
Sets the content type of the response. The content type may include
the type of character encoding used, for example <EM>text/html;
charset=ISO-8859-4</EM>.
<P>If calling <A HREF="#item_getWriter"><CODE>getWriter()</CODE></A>, this method should be called first.</P>
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24type"><EM>$type</EM></A></STRONG><BR>
<DD>
The MIME type of the content
<P></P></DL>
<DT><STRONG><A NAME="item_setLocale"><CODE>setLocale($loc)</CODE></A></STRONG><BR>
<DD>
Sets the locale of the response, setting the headers (including the
<EM>charset</EM> attribute of the <EM>Content-Type</EM>) as appropriate.
<P>This method should be called before a call to <A HREF="#item_getWriter"><CODE>getWriter()</CODE></A>.</P>
<P>By default, the response locale is the default locale for the server.</P>
<P><STRONG>Parameters:</STRONG></P>
<DL>
<DT><STRONG><A NAME="item_%24loc"><EM>$loc</EM></A></STRONG><BR>
<DD>
The locale of the response
<P></P></DL>
</DL>
<P>
<HR>
<H1><A NAME="see also">SEE ALSO</A></H1>
<P><A HREF="../../api/IO/Handle.html">the IO::Handle manpage</A></P>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Brian Moseley, <A HREF="mailto:bcm@maz.org">bcm@maz.org</A></P>

</BODY>

</HTML>