Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.core
Class CmsResponseHttpServlet  view CmsResponseHttpServlet download CmsResponseHttpServlet.java

java.lang.Object
  extended bycom.opencms.core.CmsResponseHttpServlet
All Implemented Interfaces:
I_CmsResponse

public class CmsResponseHttpServlet
extends java.lang.Object
implements I_CmsResponse

Implementation of the I_CmsResponse interface which wraps a HttpServletResponse and provides OpenCms with a facility to handle redirects.

Version:
$Revision: 1.29 $ $Date: 2003/03/19 08:43:10 $

Field Summary
private static java.lang.String C_LAST_MODIFIED
           
private static boolean DEBUG
          Debug flag
private static boolean jsdk2
          Flag to indicate what JSDK is available
private  java.lang.String m_clusterurl
          The clusterurl.
private  java.lang.String m_contentType
          String to save the content type
private  java.io.OutputStream m_orgOutputStream
          Buffer for the output stream
private  boolean m_redir
          Remember, if a redirect was sent
private  javax.servlet.http.HttpServletRequest m_req
          The original wrapped request.
private  javax.servlet.http.HttpServletResponse m_res
          The original wrapped response.
private  int m_type
          The type of this CmsResponset.
 
Constructor Summary
(package private) CmsResponseHttpServlet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String clusterurl)
          Constructor, creates a new CmsResponseHttpServlet object.
 
Method Summary
 void addHeader(java.lang.String key, java.lang.String value)
          Add a header-field in the response.
static boolean checkJsdk()
          Check the JSDK version available at runtime.
 boolean containsHeader(java.lang.String key)
          Checks, if the header was set already.
 java.lang.String getContentType()
          Returns the content type of the response which has previously been set using setContentType(java.lang.String) 55 .
 java.lang.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, which will be a C_RESPONSE_HTTP value for this wrapper implementation.
 java.io.OutputStream getOutputStream()
          Returns an OutputStream for writing the response data.
 boolean isOutputWritten()
          Check if the output stream was written previously.
 boolean isRedirected()
          Check if the current request was redirected.
 void sendCmsRedirect(java.lang.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, java.lang.String msg)
          Sets the error code and a additional message that is returnd by the response.
 void sendRedirect(java.lang.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(java.lang.String type)
          Sets the content type of the response to the specified type.
 void setHeader(java.lang.String key, java.lang.String value)
          Sets a header-field in the response.
 void setLastModified(long time)
          Sets the last modified header-field in the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_LAST_MODIFIED

private static java.lang.String C_LAST_MODIFIED

m_res

private javax.servlet.http.HttpServletResponse m_res
The original wrapped response.


m_req

private javax.servlet.http.HttpServletRequest m_req
The original wrapped request.


m_clusterurl

private java.lang.String m_clusterurl
The clusterurl.


m_type

private int m_type
The type of this CmsResponset.


m_redir

private boolean m_redir
Remember, if a redirect was sent


m_orgOutputStream

private java.io.OutputStream m_orgOutputStream
Buffer for the output stream


jsdk2

private static boolean jsdk2
Flag to indicate what JSDK is available


m_contentType

private java.lang.String m_contentType
String to save the content type


DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values
Constructor Detail

CmsResponseHttpServlet

CmsResponseHttpServlet(javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res,
                       java.lang.String clusterurl)
Constructor, creates a new CmsResponseHttpServlet object.

Method Detail

checkJsdk

public static boolean checkJsdk()
Check the JSDK version available at runtime.


getOriginalResponse

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

Specified by:
getOriginalResponse in interface I_CmsResponse

getOriginalResponseType

public int getOriginalResponseType()
Returns the type of the response that was used to create the CmsResponse, which will be a C_RESPONSE_HTTP value for this wrapper implementation.

Specified by:
getOriginalResponseType in interface I_CmsResponse

getOutputStream

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

Specified by:
getOutputStream in interface I_CmsResponse

isOutputWritten

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

Specified by:
isOutputWritten in interface I_CmsResponse

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.

Specified by:
isRedirected in interface I_CmsResponse

sendCmsRedirect

public void sendCmsRedirect(java.lang.String location)
                     throws java.io.IOException
Sets a redirect to send the responst to. The original HttpServletResponse redirect is used here. Additional information about the servlets location is taken from the original HttpServletRequest.

Specified by:
sendCmsRedirect in interface I_CmsResponse

sendError

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

Specified by:
sendError in interface I_CmsResponse

sendError

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

Specified by:
sendError in interface I_CmsResponse

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Helper function for a redirect to the cluster url. If location has the same hostname as the host of this servlet use the cluster url.

Specified by:
sendRedirect in interface I_CmsResponse

setContentLength

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

Specified by:
setContentLength in interface I_CmsResponse

setContentType

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

Specified by:
setContentType in interface I_CmsResponse

getContentType

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

Specified by:
getContentType in interface I_CmsResponse

setHeader

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

Specified by:
setHeader in interface I_CmsResponse

addHeader

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

Specified by:
addHeader in interface I_CmsResponse

setLastModified

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

Specified by:
setLastModified in interface I_CmsResponse

containsHeader

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

Specified by:
containsHeader in interface I_CmsResponse