com.opencms.core
Interface I_CmsResponse

All Known Implementing Classes:
CmsExportResponse, CmsResponseHttpServlet

public interface I_CmsResponse

This interface defines an OpenCms response, a generic response object that is used by OpenCms and provides methods to send processed data back to the requesting user.

Implementations of this interface use an existing response (e.g. HttpServletResponse) to initialize an I_CmsResponse.

Version:
$Revision: 1.16 $ $Date: 2003/01/20 23:59:20 $
Author:
Michael Emmerich, Alexander Kandzior

Method Summary
 void addHeader(String key, String value)
          Add a header-field in the response.
 boolean containsHeader(String key)
          Checks, if the header was set already.
 String getContentType()
          Returns the content type of the response which has previously been set using setContentType(java.lang.String).
 Object getOriginalResponse()
          Returns the original response that was used to create the CmsResponse.
 int getOriginalResponseType()
          Returns the type of the response that was used to create the CmsResponse.
 OutputStream getOutputStream()
          Returns an OutputStream for writing the response data.
 boolean isOutputWritten()
          Check if the output stream was requested previously.
 boolean isRedirected()
          Check if the current request was redirected.
 void sendCmsRedirect(String location)
          Sets a redirect to send the responst to.
 void sendError(int code)
          Sets the error code that is returnd by the response.
 void sendError(int code, String msg)
          Sets the error code and a additional message that is returnd by the response.
 void sendRedirect(String location)
          Helper function for a redirect to the cluster url.
 void setContentLength(int len)
          Sets the length of the content being returned by the server.
 void setContentType(String type)
          Sets the content type of the response to the specified type.
 void setHeader(String key, String value)
          Sets a header-field in the response.
 void setLastModified(long time)
          Sets the last modified header-field in the response.
 

Method Detail

getOriginalResponse

public Object getOriginalResponse()
Returns the original response that was used to create the CmsResponse.

Returns:
The original response of the CmsResponse.

getOriginalResponseType

public int getOriginalResponseType()
Returns the type of the response that was used to create the CmsResponse. The returned int must be one of the constants defined above in this interface.

Returns:
The type of the CmsResponse.

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Returns an OutputStream for writing the response data.

Returns:
OutputStream for writing data.
Throws:
Throws - IOException if an error occurs.
IOException

isOutputWritten

public boolean isOutputWritten()
Check if the output stream was requested previously.

Returns:
true if getOutputStream() was called, false otherwise.

isRedirected

public boolean isRedirected()
Check if the current request was redirected. In this case, the servlet must not write any bytes to the output stream.

Returns:
true if the request is redirected, false otherwise.

sendCmsRedirect

public void sendCmsRedirect(String location)
                     throws IOException
Sets a redirect to send the responst to.

Parameters:
location - The location the response is send to.
Throws:
Throws - IOException if an error occurs.
IOException

sendError

public void sendError(int code)
               throws IOException
Sets the error code that is returnd by the response. The error code is specified by a numeric value.

Parameters:
code - The error code to be set.
Throws:
Throws - IOException if an error occurs.
IOException

sendError

public void sendError(int code,
                      String msg)
               throws IOException
Sets the error code and a additional message that is returnd by the response. The error code is specified by a numeric value.

Parameters:
code - The error code to be set.
msg - Additional error message.
Throws:
Throws - IOException if an error occurs.
IOException

sendRedirect

public void sendRedirect(String location)
                  throws IOException
Helper function for a redirect to the cluster url.

Parameters:
location - a complete url, eg. http://servername/servlets/opencms/index.html
Throws:
Throws - IOException if an error occurs.
IOException

setContentLength

public void setContentLength(int len)
Sets the length of the content being returned by the server.

Parameters:
len - Number of bytes to be returned by the response.

setContentType

public void setContentType(String type)
Sets the content type of the response to the specified type.

Parameters:
type - The contnent type of the response.

getContentType

public String getContentType()
Returns the content type of the response which has previously been set using setContentType(java.lang.String).

Returns:
the content type of the response.

setHeader

public void setHeader(String key,
                      String value)
Sets a header-field in the response.

Parameters:
key - The key for the header.
value - The value for the header.

addHeader

public void addHeader(String key,
                      String value)
Add a header-field in the response.

Parameters:
key - The key for the header.
value - The value for the header.

setLastModified

public void setLastModified(long time)
Sets the last modified header-field in the response.

Parameters:
time - The last-modified time.

containsHeader

public boolean containsHeader(String key)
Checks, if the header was set already.

Returns:
true, if the header was set before else false.