org.apache.cocoon.environment.http
Class HttpEnvironment

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.environment.AbstractEnvironment
          extended byorg.apache.cocoon.environment.http.HttpEnvironment
All Implemented Interfaces:
org.apache.cocoon.environment.Environment

public class HttpEnvironment
extends AbstractEnvironment

HTTP Servlet environment.

Version:
$Id: HttpEnvironment.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
static String HTTP_REQUEST_OBJECT
           
static String HTTP_RESPONSE_OBJECT
           
static String HTTP_SERVLET_CONTEXT
           
 
Fields inherited from class org.apache.cocoon.environment.AbstractEnvironment
action, objectModel, outputStream, prefix, secureOutputStream, uri, view
 
Constructor Summary
HttpEnvironment(String uri, HttpServletRequest req, HttpServletResponse res, ServletContext servletContext, org.apache.cocoon.environment.Context context, String containerEncoding, String defaultFormEncoding)
          Constructs a HttpEnvironment object from a HttpServletRequest and HttpServletResponse objects
 
Method Summary
 String getContentType()
          Get the ContentType
 OutputStream getOutputStream(int bufferSize)
          Get the output stream where to write the generated resource.
 boolean isExternal()
          Always return true.
 boolean isResponseModified(long lastModified)
          Check if the response has been modified since the same "resource" was requested.
 void redirect(String newURL, boolean global, boolean permanent)
          Redirect the client to new URL
 void setContentLength(int length)
          Set the length of the generated content
 void setContentType(String contentType)
          Set the ContentType
 void setResponseIsNotModified()
          Mark the response as not modified.
 void setStatus(int statusCode)
          Set the StatusCode
 boolean tryResetResponse()
          Reset the response if possible.
 
Methods inherited from class org.apache.cocoon.environment.AbstractEnvironment
commitResponse, extractAction, extractView, finishingProcessing, getAction, getAttribute, getAttributeNames, getObjectModel, getURI, getURIPrefix, getView, isInternalRedirect, removeAttribute, setAction, setAttribute, setURI, setView, startingProcessing
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_REQUEST_OBJECT

public static final String HTTP_REQUEST_OBJECT
See Also:
Constant Field Values

HTTP_RESPONSE_OBJECT

public static final String HTTP_RESPONSE_OBJECT
See Also:
Constant Field Values

HTTP_SERVLET_CONTEXT

public static final String HTTP_SERVLET_CONTEXT
See Also:
Constant Field Values
Constructor Detail

HttpEnvironment

public HttpEnvironment(String uri,
                       HttpServletRequest req,
                       HttpServletResponse res,
                       ServletContext servletContext,
                       org.apache.cocoon.environment.Context context,
                       String containerEncoding,
                       String defaultFormEncoding)
                throws IOException
Constructs a HttpEnvironment object from a HttpServletRequest and HttpServletResponse objects

Method Detail

redirect

public void redirect(String newURL,
                     boolean global,
                     boolean permanent)
              throws IOException
Redirect the client to new URL

Throws:
IOException

setStatus

public void setStatus(int statusCode)
Set the StatusCode

Specified by:
setStatus in interface org.apache.cocoon.environment.Environment
Overrides:
setStatus in class AbstractEnvironment

setContentType

public void setContentType(String contentType)
Set the ContentType


getContentType

public String getContentType()
Get the ContentType


setContentLength

public void setContentLength(int length)
Set the length of the generated content


isResponseModified

public boolean isResponseModified(long lastModified)
Check if the response has been modified since the same "resource" was requested. The caller has to test if it is really the same "resource" which is requested.

Specified by:
isResponseModified in interface org.apache.cocoon.environment.Environment
Overrides:
isResponseModified in class AbstractEnvironment
Returns:
true if the response is modified or if the environment is not able to test it

setResponseIsNotModified

public void setResponseIsNotModified()
Mark the response as not modified.

Specified by:
setResponseIsNotModified in interface org.apache.cocoon.environment.Environment
Overrides:
setResponseIsNotModified in class AbstractEnvironment

tryResetResponse

public boolean tryResetResponse()
                         throws IOException
Reset the response if possible. This allows error handlers to have a higher chance to produce clean output if the pipeline that raised the error has already output some data.

Specified by:
tryResetResponse in interface org.apache.cocoon.environment.Environment
Overrides:
tryResetResponse in class AbstractEnvironment
Returns:
true if the response was successfully reset
Throws:
IOException

getOutputStream

public OutputStream getOutputStream(int bufferSize)
                             throws IOException
Get the output stream where to write the generated resource. The returned stream is buffered by the environment. If the buffer size is -1 then the complete output is buffered. If the buffer size is 0, no buffering takes place.

Specified by:
getOutputStream in interface org.apache.cocoon.environment.Environment
Overrides:
getOutputStream in class AbstractEnvironment
Throws:
IOException

isExternal

public boolean isExternal()
Always return true.



Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.