FileDocCategorySizeDatePackage
ApplicationHttpResponse.javaAPI DocApache Tomcat 6.0.1410117Fri Jul 20 04:20:34 BST 2007org.apache.catalina.core

ApplicationHttpResponse

public class ApplicationHttpResponse extends HttpServletResponseWrapper
Wrapper around a javax.servlet.http.HttpServletResponse that transforms an application response object (which might be the original one passed to a servlet, or might be based on the 2.3 javax.servlet.http.HttpServletResponseWrapper class) back into an internal org.apache.catalina.HttpResponse.

WARNING: Due to Java's lack of support for multiple inheritance, all of the logic in ApplicationResponse is duplicated in ApplicationHttpResponse. Make sure that you keep these two classes in synchronization when making changes!

author
Craig R. McClanahan
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
protected boolean
included
Is this wrapped response the subject of an include() call?
protected static final String
info
Descriptive information about this implementation.
protected static org.apache.catalina.util.StringManager
sm
The string manager for this package.
Constructors Summary
public ApplicationHttpResponse(HttpServletResponse response)
Construct a new wrapped response around the specified servlet response.

param
response The servlet response being wrapped


        this(response, false);

    
public ApplicationHttpResponse(HttpServletResponse response, boolean included)
Construct a new wrapped response around the specified servlet response.

param
response The servlet response being wrapped
param
included true if this response is being processed by a RequestDispatcher.include() call


        super(response);
        setIncluded(included);

    
Methods Summary
public voidaddCookie(javax.servlet.http.Cookie cookie)
Disallow addCookie() calls on an included response.

param
cookie The new cookie


        if (!included)
            ((HttpServletResponse) getResponse()).addCookie(cookie);

    
public voidaddDateHeader(java.lang.String name, long value)
Disallow addDateHeader() calls on an included response.

param
name The new header name
param
value The new header value


        if (!included)
            ((HttpServletResponse) getResponse()).addDateHeader(name, value);

    
public voidaddHeader(java.lang.String name, java.lang.String value)
Disallow addHeader() calls on an included response.

param
name The new header name
param
value The new header value


        if (!included)
            ((HttpServletResponse) getResponse()).addHeader(name, value);

    
public voidaddIntHeader(java.lang.String name, int value)
Disallow addIntHeader() calls on an included response.

param
name The new header name
param
value The new header value


        if (!included)
            ((HttpServletResponse) getResponse()).addIntHeader(name, value);

    
public java.lang.StringgetInfo()
Return descriptive information about this implementation.


        return (info);

    
booleanisIncluded()
Return the included flag for this response.


        return (this.included);

    
public voidreset()
Disallow reset() calls on a included response.

exception
IllegalStateException if the response has already been committed



    // ------------------------------------------------ ServletResponse Methods


                          
       

        // If already committed, the wrapped response will throw ISE
        if (!included || getResponse().isCommitted())
            getResponse().reset();

    
public voidsendError(int sc)
Disallow sendError() calls on an included response.

param
sc The new status code
exception
IOException if an input/output error occurs


        if (!included)
            ((HttpServletResponse) getResponse()).sendError(sc);

    
public voidsendError(int sc, java.lang.String msg)
Disallow sendError() calls on an included response.

param
sc The new status code
param
msg The new message
exception
IOException if an input/output error occurs


        if (!included)
            ((HttpServletResponse) getResponse()).sendError(sc, msg);

    
public voidsendRedirect(java.lang.String location)
Disallow sendRedirect() calls on an included response.

param
location The new location
exception
IOException if an input/output error occurs


        if (!included)
            ((HttpServletResponse) getResponse()).sendRedirect(location);

    
public voidsetBufferSize(int size)
Ignore setBufferSize() calls on an included response.

param
size The buffer size

        if (!included)
            getResponse().setBufferSize(size);
    
public voidsetContentLength(int len)
Disallow setContentLength() calls on an included response.

param
len The new content length


        if (!included)
            getResponse().setContentLength(len);

    
public voidsetContentType(java.lang.String type)
Disallow setContentType() calls on an included response.

param
type The new content type


        if (!included)
            getResponse().setContentType(type);

    
public voidsetDateHeader(java.lang.String name, long value)
Disallow setDateHeader() calls on an included response.

param
name The new header name
param
value The new header value


        if (!included)
            ((HttpServletResponse) getResponse()).setDateHeader(name, value);

    
public voidsetHeader(java.lang.String name, java.lang.String value)
Disallow setHeader() calls on an included response.

param
name The new header name
param
value The new header value


        if (!included)
            ((HttpServletResponse) getResponse()).setHeader(name, value);

    
voidsetIncluded(boolean included)
Set the included flag for this response.

param
included The new included flag


        this.included = included;

    
public voidsetIntHeader(java.lang.String name, int value)
Disallow setIntHeader() calls on an included response.

param
name The new header name
param
value The new header value


        if (!included)
            ((HttpServletResponse) getResponse()).setIntHeader(name, value);

    
public voidsetLocale(java.util.Locale loc)
Disallow setLocale() calls on an included response.

param
loc The new locale


        if (!included)
            getResponse().setLocale(loc);

    
voidsetResponse(javax.servlet.http.HttpServletResponse response)
Set the response that we are wrapping.

param
response The new wrapped response


        super.setResponse(response);

    
public voidsetStatus(int sc)
Disallow setStatus() calls on an included response.

param
sc The new status code


        if (!included)
            ((HttpServletResponse) getResponse()).setStatus(sc);

    
public voidsetStatus(int sc, java.lang.String msg)
Disallow setStatus() calls on an included response.

param
sc The new status code
param
msg The new message


        if (!included)
            ((HttpServletResponse) getResponse()).setStatus(sc, msg);