Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    * 
    *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  package org.apache.catalina.connector;
  
  
  import static org.jboss.web.CatalinaMessages.MESSAGES;
  
  import java.io.File;
  import java.util.Locale;
  import java.util.Vector;
  
  
Wrapper object for the Coyote response.

Author(s):
Remy Maucherat
Craig R. McClanahan
Version:
$Revision: 2025 $ $Date: 2012-04-16 12:24:28 +0200 (Mon, 16 Apr 2012) $
  
  
  public class Response
      implements HttpServletResponse {
  
  
      // ----------------------------------------------------------- Constructors
  
      static {
          // Ensure that URL is loaded for SM
          URL.isSchemeChar('c');
      }
  
      public Response() {
          .addSafeCharacter('/');
      }
  
  
      // ----------------------------------------------------- Class Variables
  

    
Descriptive information about this Response implementation.
  
      protected static final String info =
          "org.apache.coyote.tomcat5.CoyoteResponse/1.0";
  
  
      // ----------------------------------------------------- Instance Variables
  
    
The date format we will use for creating date headers.
 
     protected SimpleDateFormat format = null;
 
 
     // ------------------------------------------------------------- Properties
 

    
Associated Catalina connector.
 
     protected Connector connector;

    
Return the Connector through which this Request was received.
 
     public Connector getConnector() {
         return (this.);
     }

    
Set the Connector through which this Request was received.

Parameters:
connector The new connector
 
     public void setConnector(Connector connector) {
         this. = connector;
         if("AJP/1.3".equals(connector.getProtocol())) {
             // default size to size of one ajp-packet
              = new OutputBuffer(this, 8184);
         } else {
              = new OutputBuffer(this);
         }
          = new CoyoteOutputStream();
          = new CoyoteWriter();
     }


    
Coyote response.
 
     protected org.apache.coyote.Response coyoteResponse;

    
Set the Coyote response.

Parameters:
coyoteResponse The Coyote response
 
     public void setCoyoteResponse(org.apache.coyote.Response coyoteResponse) {
         this. = coyoteResponse;
         .setResponse(coyoteResponse);
     }

    
Get the Coyote response.
 
         return ();
     }


    
The associated output buffer.
 
     protected OutputBuffer outputBuffer;


    
The associated output stream.
 
     protected CoyoteOutputStream outputStream;


    
The associated writer.
 
     protected CoyoteWriter writer;


    
The application commit flag.
 
     protected boolean appCommitted = false;


    
The included flag.
 
     protected boolean included = false;

    
    
The characterEncoding flag
 
     private boolean isCharacterEncodingSet = false;
    
    
The error flag.
 
     protected boolean error = false;


    
The set of Cookies associated with this Response.
 
     protected ArrayList cookies = new ArrayList();


    
Using output stream flag.
 
     protected boolean usingOutputStream = false;


    
Using writer flag.
 
     protected boolean usingWriter = false;


    
Application output stream.
 
     protected ServletOutputStream applicationOutputStream = null;


    
Using writer flag.
 
     protected PrintWriter applicationWriter = null;


    
URL encoder.
 
     protected UEncoder urlEncoder = new UEncoder();


    
Recyclable buffer to hold the redirect URL.
 
     protected CharChunk redirectURLCC = new CharChunk();
 
 
     // --------------------------------------------------------- Public Methods
 

    
Release all object references, and initialize instance variables, in preparation for reuse of this object.
 
     public void recycle() {
 
         .recycle();
          = false;
          = false;
          = null;
          = null;
          = false;
          = false;
          = false;
          = false;
         
         .clear();
 
             if ( != null) {
                 .clear();
                  = null;
             }
             if ( != null) {
                 .clear();
                  = null;
             }
             if ( != null) {
                 .clear();
                  = null;
             }
         } else {
             .recycle();
         }
 
     }


    
Clear cached encoders (to save memory for event or async requests).
 
     public void clearEncoders() {
         .clearEncoders();
     }
    

    
Clear output stream.
 
     public void clearOutputStream() {
         if ( != null) {
             .clear();
              = null;
         }
     }
     
 
     // ------------------------------------------------------- Response Methods
 

    
Return the number of bytes actually written to the output stream.
 
     public int getContentCount() {
         return .getContentWritten();
     }
    
    
Return the number of bytes actually written to the output stream.
 
     public long getContentCountLong() {
         return .getContentWrittenLong();
     }

    
Set the application commit flag.

Parameters:
appCommitted The new application committed flag value
 
     public void setAppCommitted(boolean appCommitted) {
         this. = appCommitted;
     }


    
Application commit flag accessor.
 
     public boolean isAppCommitted() {
         return (this. || isCommitted() || isSuspended()
                 || ((getContentLength() > 0) 
                     && (getContentCount() >= getContentLength())));
     }


    
Return the "processing inside an include" flag.
 
     public boolean getIncluded() {
         return ;
     }


    
Set the "processing inside an include" flag.

Parameters:
included true if we are currently inside a RequestDispatcher.include(), else false
 
     public void setIncluded(boolean included) {
         this. = included;
     }


    
Return descriptive information about this Response implementation and the corresponding version number, in the format <description>/<version>.
 
     public String getInfo() {
         return ();
     }


    
The request with which this response is associated.
 
     protected Request request = null;

    
Return the Request with which this Response is associated.
 
         return (this.);
     }

    
Set the Request with which this Response is associated.

Parameters:
request The new associated request
 
     public void setRequest(org.apache.catalina.connector.Request request) {
         this. = (Requestrequest;
     }


    
The facade associated with this response.
 
     protected ResponseFacade facade = null;

    
Return the ServletResponse for which this object is the facade.
 
     public HttpServletResponse getResponse() {
         if ( == null) {
              = new ResponseFacade(this);
         }
         return ();
     }


    
Return the output stream associated with this Response.
 
     public OutputStream getStream() {
         if ( == null) {
              = new CoyoteOutputStream();
         }
         return ;
     }


    
Set the suspended flag.

Parameters:
suspended The new suspended flag value
 
     public void setSuspended(boolean suspended) {
         .setSuspended(suspended);
     }


    
Suspended flag accessor.
 
     public boolean isSuspended() {
         return .isSuspended();
     }


    
Closed flag accessor.
 
     public boolean isClosed() {
         return .isClosed();
     }


    
Set the error flag.
 
     public void setError() {
          = true;
     }


    
Error flag accessor.
 
     public boolean isError() {
         return ;
     }


    
Create and return a ServletOutputStream to write the content associated with this Response.

Throws:
java.io.IOException if an input/output error occurs
 
         throws IOException {
         // Probably useless
         if ( == null) {
              = new CoyoteOutputStream();
         }
         return ;
     }


    
Perform whatever actions are required to flush and close the output stream or writer, in a single operation.

Throws:
java.io.IOException if an input/output error occurs
 
     public void finishResponse() 
         throws IOException {
         // Writing leftover bytes
         .close();
     }


    
Return the content length that was set or calculated for this Response.
 
     public int getContentLength() {
         return (.getContentLength());
     }


    
Return the content type that was set or calculated for this response, or null if no content type was set.
 
     public String getContentType() {
         return (.getContentType());
     }


    
Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired.

Returns:
Writer which can be used for error reports. If the response is not an error report returned using sendError or triggered by an unexpected exception thrown during the servlet processing (and only in that case), null will be returned if the response stream has already been used.
Throws:
java.io.IOException if an input/output error occurs
 
     public PrintWriter getReporter() throws IOException {
         if (.isNew()) {
             .checkConverter();
             if ( == null) {
                  = new CoyoteWriter();
             }
             return ;
         } else {
             return null;
         }
     }


    
Return true if bytes are available.
 
     public boolean isWriteable() {
         return (.lastWrite() > 0);
     }
 
     
     // ------------------------------------------------ ServletResponse Methods
 

    
Flush the buffer and commit this response.

Throws:
java.io.IOException if an input/output error occurs
 
     public void flushBuffer() 
         throws IOException {
         .flush();
     }


    
Return the actual buffer size used for this Response.
 
     public int getBufferSize() {
         return .getBufferSize();
     }


    
Return the character encoding used for this Response.
 
     public String getCharacterEncoding() {
         return (.getCharacterEncoding());
     }


    
Return the servlet output stream associated with this Response.

Throws:
java.lang.IllegalStateException if getWriter has already been called for this response
java.io.IOException if an input/output error occurs
 
         throws IOException {
 
         if ()
             throw .writerAlreadyUsed();
 
         if ( != null) {
             return ;
         }
         
          = true;
         if ( == null) {
              = new CoyoteOutputStream();
         }
         return ;
 
     }
 
     
     public void setOutputStream(ServletOutputStream outputStream) {
          = outputStream;
     }


    
Return the Locale assigned to this response.
 
     public Locale getLocale() {
         return (.getLocale());
     }


    
Return the writer associated with this Response.

Throws:
java.lang.IllegalStateException if getOutputStream has already been called for this response
java.io.IOException if an input/output error occurs
 
     public PrintWriter getWriter() 
         throws IOException {
 
         if ()
             throw .outputStreamAlreadyUsed();
 
         if ( != null) {
             return ;
         }
 
         if (.) {
             /*
              * If the response's character encoding has not been specified as
              * described in <code>getCharacterEncoding</code> (i.e., the method
              * just returns the default value <code>ISO-8859-1</code>),
              * <code>getWriter</code> updates it to <code>ISO-8859-1</code>
              * (with the effect that a subsequent call to getContentType() will
              * include a charset=ISO-8859-1 component which will also be
              * reflected in the Content-Type response header, thereby satisfying
              * the Servlet spec requirement that containers must communicate the
              * character encoding used for the servlet response's writer to the
              * client).
              */
             setCharacterEncoding(getCharacterEncoding());
         }
 
          = true;
         .checkConverter();
         if ( == null) {
              = new CoyoteWriter();
         }
         return ;
 
     }
 
 
     public void setWriter(PrintWriter writer) {
          = writer;
     }


    
Has the output of this response already been committed?
 
     public boolean isCommitted() {
         return (.isCommitted());
     }


    
Clear any content written to the buffer.

Throws:
java.lang.IllegalStateException if this response has already been committed
 
     public void reset() {
 
         if ()
             return;     // Ignore any call from an included servlet
 
         .reset();
         .reset();
          = false;
          = false;
          = false;
     }


    
Reset the data buffer but not any status or header information.

Throws:
java.lang.IllegalStateException if the response has already been committed
 
     public void resetBuffer() {
 
         if (isCommitted())
             throw .cannotResetBuffer();
 
         .reset();
 
     }


    
Reset the data buffer and the using Writer/Stream flags but not any status or header information.

Parameters:
resetWriterStreamFlags true if the internal usingWriter, usingOutputStream, isCharacterEncodingSet flags should also be reset
Throws:
java.lang.IllegalStateException if the response has already been committed
 
     public void resetBuffer(boolean resetWriterStreamFlags) {
 
         resetBuffer();
         
         if(resetWriterStreamFlags) {
              = false;
              = false;
              = false;
         }
 
     }

    
    
Set the buffer size to be used for this Response.

Parameters:
size The new buffer size
Throws:
java.lang.IllegalStateException if this method is called after output has been committed for this response
 
     public void setBufferSize(int size) {
 
         if (isCommitted() || !.isNew())
             throw .cannotChangeBufferSize();
 
         .setBufferSize(size);
 
     }


    
Set the content length (in bytes) for this Response.

Parameters:
length The new content length
 
     public void setContentLength(int length) {
 
         if (isCommitted())
             return;
 
         // Ignore any call from an included servlet
         if ()
             return;
         
         if ()
             return;
         
         .setContentLength(length);
 
     }


    
Set the content type for this Response.

Parameters:
type The new content type
 
     public void setContentType(String type) {
 
         if (isCommitted())
             return;
 
         // Ignore any call from an included servlet
         if ()
             return;
 
         // Ignore charset if getWriter() has already been called
         if () {
             if (type != null) {
                 int index = type.indexOf(";");
                 if (index != -1) {
                     type = type.substring(0, index);
                 }
             }
         }
 
         .setContentType(type);
 
         // Check to see if content type contains charset
         if (type != null) {
             int index = type.indexOf(";");
             if (index != -1) {
                 int len = type.length();
                 index++;
                 while (index < len && Character.isSpace(type.charAt(index))) {
                     index++;
                 }
                 if (index+7 < len
                         && type.charAt(index) == 'c'
                         && type.charAt(index+1) == 'h'
                         && type.charAt(index+2) == 'a'
                         && type.charAt(index+3) == 'r'
                         && type.charAt(index+4) == 's'
                         && type.charAt(index+5) == 'e'
                         && type.charAt(index+6) == 't'
                         && type.charAt(index+7) == '=') {
                      = true;
                 }
             }
         }
     }
 
 
     /*
      * Overrides the name of the character encoding used in the body
      * of the request. This method must be called prior to reading
      * request parameters or reading input using getReader().
      *
      * @param charset String containing the name of the chararacter encoding.
      */
     public void setCharacterEncoding(String charset) {
 
         if (isCommitted())
             return;
         
         // Ignore any call from an included servlet
         if ()
             return;     
         
         // Ignore any call made after the getWriter has been invoked
         // The default should be used
         if ()
             return;
 
         .setCharacterEncoding(charset);
          = true;
     }

    
    
    
Set the Locale that is appropriate for this response, including setting the appropriate character encoding.

Parameters:
locale The new locale
 
     public void setLocale(Locale locale) {
 
         if (isCommitted())
             return;
 
         // Ignore any call from an included servlet
         if ()
             return;
 
         .setLocale(locale);
 
         // Ignore any call made after the getWriter has been invoked.
         // The default should be used
         if ()
             return;
 
         if () {
             return;
         }
 
         CharsetMapper cm = .getContext().getCharsetMapper();
         String charset = cm.getCharsetlocale );
         if ( charset != null ){
             .setCharacterEncoding(charset);
         }
 
     }
 
 
     // --------------------------------------------------- HttpResponse Methods
 

    
Return an array of all cookies set for this response, or a zero-length array if no cookies have been set.
 
     public Cookie[] getCookies() {
         return ((Cookie[]) .toArray(new Cookie[.size()]));
     }


    
Return the value for the specified header, or null if this header has not been set. If more than one value was added for this name, only the first is returned; use getHeaderValues() to retrieve all of them.

Parameters:
name Header name to look up
 
     public String getHeader(String name) {
         return .getMimeHeaders().getHeader(name);
     }


    
Return an array of all the header names set for this response, or a zero-length array if no headers have been set.
 
     public Collection<StringgetHeaderNames() {
         MimeHeaders headers = .getMimeHeaders();
         Collection<StringheadersCollection = new ArrayList<String>();
         int n = headers.size();
         for (int i = 0; i < ni++) {
             headersCollection.add(headers.getName(i).toString());
         }
         return headersCollection;
     }


    
Return an array of all the header names set for this response, or a zero-length array if no headers have been set.
 
     public String[] getHeaderNamesArray() {
 
         MimeHeaders headers = .getMimeHeaders();
         int n = headers.size();
         String[] result = new String[n];
         for (int i = 0; i < ni++) {
             result[i] = headers.getName(i).toString();
         }
         return result;
 
     }


    
Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values.

Parameters:
name Header name to look up
 
     public Collection<StringgetHeaders(String name) {
         Enumeration enumeration = .getMimeHeaders().values(name);
         Collection<StringheaderValuesCollection = new ArrayList<String>();
         while (enumeration.hasMoreElements()) {
             headerValuesCollection.add((Stringenumeration.nextElement());
         }
         return headerValuesCollection;
     }
    
    
    
Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values.

Parameters:
name Header name to look up
 
     public String[] getHeaderValues(String name) {
 
         Enumeration enumeration = .getMimeHeaders().values(name);
         Vector result = new Vector();
         while (enumeration.hasMoreElements()) {
             result.addElement(enumeration.nextElement());
         }
         String[] resultArray = new String[result.size()];
         result.copyInto(resultArray);
         return resultArray;
 
     }


    
Return the error message that was set with sendError() for this Response.
 
     public String getMessage() {
         return .getMessage();
     }


    
Return the HTTP status code associated with this Response.
 
     public int getStatus() {
         return .getStatus();
     }


    
Reset this response, and specify the values for the HTTP status code and corresponding message.

Throws:
java.lang.IllegalStateException if this response has already been committed
 
     public void reset(int statusString message) {
         reset();
         setStatus(statusmessage);
    }
    // -------------------------------------------- HttpServletResponse Methods


    
Add the specified Cookie to those that will be included with this Response.

Parameters:
cookie Cookie to be added
    public void addCookie(final Cookie cookie) {
        // Ignore any call from an included servlet
        if ()
            return;
        addCookieInternal(cookie);
    }


    
Add the specified Cookie to those that will be included with this Response.

Parameters:
cookie Cookie to be added
    public void addCookieInternal(final Cookie cookie) {
        if (isCommitted())
            return;
        final StringBuffer sb = new StringBuffer();
        // web application code can receive a IllegalArgumentException 
        // from the appendCookieValue invocation
        if (SecurityUtil.isPackageProtectionEnabled()) {
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run(){
                    ServerCookie.appendCookieValue
                        (sbcookie.getVersion(), cookie.getName(), 
                         cookie.getValue(), cookie.getPath(), 
                         cookie.getDomain(), cookie.getComment(), 
                         cookie.getMaxAge(), cookie.getSecure(), cookie.isHttpOnly());
                    return null;
                }
            });
        } else {
            ServerCookie.appendCookieValue
                (sbcookie.getVersion(), cookie.getName(), cookie.getValue(),
                     cookie.getPath(), cookie.getDomain(), cookie.getComment(), 
                     cookie.getMaxAge(), cookie.getSecure(), cookie.isHttpOnly());
        }
        // if we reached here, no exception, cookie is valid
        // the header name is Set-Cookie for both "old" and v.1 ( RFC2109 )
        // RFC2965 is not supported by browsers and the Servlet spec
        // asks for 2109.
        addHeader("Set-Cookie"sb.toString());
        .add(cookie);
    }


    
Add the specified date header to the specified value.

Parameters:
name Name of the header to set
value Date value to be set
    public void addDateHeader(String namelong value) {
        if (name == null || name.length() == 0) {
            return;
        }
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if () {
            return;
        }
        if ( == null) {
                                          .);
            .setTimeZone(TimeZone.getTimeZone("GMT"));
        }
        addHeader(name, FastHttpDateFormat.formatDate(value));
    }


    
Add the specified header to the specified value.

Parameters:
name Name of the header to set
value Value to be set
    public void addHeader(String nameString value) {
        if (name == null || name.length() == 0 || value == null) {
            return;
        }
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return;
        .addHeader(namevalue);
    }


    
Add the specified integer header to the specified value.

Parameters:
name Name of the header to set
value Integer value to be set
    public void addIntHeader(String nameint value) {
        if (name == null || name.length() == 0) {
            return;
        }
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return;
        addHeader(name"" + value);
    }


    
Has the specified header been set already in this response?

Parameters:
name Name of the header to check
    public boolean containsHeader(String name) {
        // Need special handling for Content-Type and Content-Length due to
        // special handling of these in coyoteResponse
        char cc=name.charAt(0);
        if(cc=='C' || cc=='c') {
            if(name.equalsIgnoreCase("Content-Type")) {
                // Will return null if this has not been set
                return (.getContentType() != null);
            }
            if(name.equalsIgnoreCase("Content-Length")) {
                // -1 means not known and is not sent to client
                return (.getContentLengthLong() != -1);
            }
        }
        return .containsHeader(name);
    }


    
Encode the session identifier associated with this response into the specified redirect URL, if necessary.

Parameters:
url URL to be encoded
    public String encodeRedirectURL(String url) {
        if (isEncodeable(toAbsolute(url))) {
            return (toEncoded(url.getSessionInternal().getIdInternal()));
        } else {
            return (url);
        }
    }


    
Encode the session identifier associated with this response into the specified redirect URL, if necessary.

Deprecated:
As of Version 2.1 of the Java Servlet API, use encodeRedirectURL() instead.
Parameters:
url URL to be encoded
    public String encodeRedirectUrl(String url) {
        return (encodeRedirectURL(url));
    }


    
Encode the session identifier associated with this response into the specified URL, if necessary.

Parameters:
url URL to be encoded
    public String encodeURL(String url) {
        
        String absolute = toAbsolute(url);
        if (isEncodeable(absolute)) {
            // W3c spec clearly said 
            if (url.equalsIgnoreCase("")){
                url = absolute;
            }
            return (toEncoded(url.getSessionInternal().getIdInternal()));
        } else {
            return (url);
        }
    }


    
Encode the session identifier associated with this response into the specified URL, if necessary.

Deprecated:
As of Version 2.1 of the Java Servlet API, use encodeURL() instead.
Parameters:
url URL to be encoded
    public String encodeUrl(String url) {
        return (encodeURL(url));
    }


    
Send an acknowledgment of a request.

Throws:
java.io.IOException if an input/output error occurs
    public void sendAcknowledgement()
        throws IOException {
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return
        .acknowledge();
    }


    
Send an error response with the specified status and a default message.

Parameters:
status HTTP status code to send
Throws:
java.lang.IllegalStateException if this response has already been committed
java.io.IOException if an input/output error occurs
    public void sendError(int status
        throws IOException {
        sendError(statusnull);
    }


    
Send an error response with the specified status and message.

Parameters:
status HTTP status code to send
message Corresponding message to send
Throws:
java.lang.IllegalStateException if this response has already been committed
java.io.IOException if an input/output error occurs
    public void sendError(int statusString message
        throws IOException {
        if (isCommitted())
            throw .cannotSendError();
        // Ignore any call from an included servlet
        if ()
            return
        Wrapper wrapper = getRequest().getWrapper();
        if (wrapper != null) {
            wrapper.incrementErrorCount();
        } 
        setError();
        .setStatus(status);
        .setMessage(message);
        // Clear any data content that has been buffered
        resetBuffer();
        // Cause the response to be finished (from the application perspective)
        setSuspended(true);
    }


    
Send a temporary redirect to the specified redirect location URL.

Parameters:
location Location URL to redirect to
Throws:
java.lang.IllegalStateException if this response has already been committed
java.io.IOException if an input/output error occurs
    public void sendRedirect(String location
        throws IOException {
        if (isCommitted())
            throw .cannotSendRedirect();
        // Ignore any call from an included servlet
        if ()
            return
        // Clear any data content that has been buffered
        resetBuffer();
        // Generate a temporary redirect to the specified location
        try {
            String absolute = toAbsolute(location);
            setStatus();
            setHeader("Location"absolute);
        } catch (IllegalArgumentException e) {
            setStatus();
        }
        // Cause the response to be finished (from the application perspective)
        setSuspended(true);
    }
    public void startUpgrade() {
        if (isCommitted())
            throw .cannotSendUpgrade();
        if (!.hasIoEvents())
            throw .cannotUpgradeWithoutEvents();
        // Ignore any call from an included servlet
        if ()
            return
    }
    public void sendUpgrade()
            throws IOException {
        if (isCommitted())
            throw .cannotSendUpgrade();
        if (!.hasIoEvents())
            throw .cannotUpgradeWithoutEvents();
        // Ignore any call from an included servlet
        if ()
            return
        // Output required by RFC2616. Protocol specific headers should have
        // already been set.
        .flush();
    }
    public void sendFile(String pathString absolutePathlong startlong end) {
        if (isCommitted())
            throw .cannotSendFile();
        // Ignore any call from an included servlet
        if ()
            return
        if (!.hasSendfile())
            throw .noSendFile();
        if (.) {
            if (path != null) {
                CacheEntry cacheEntry = 
                    ((ProxyDirContext.getContext().getResources()).lookupCache(path);
                if (cacheEntry.exists && cacheEntry.resource != null && (end > start)
                        && cacheEntry.attributes.getCanonicalPath() != null) {
                    .setSendfilePath(cacheEntry.attributes.getCanonicalPath());
                    .setSendfileStart(start);
                    .setSendfileEnd(end);
                }
            } else if (absolutePath != null) {
                String canonicalPath = null;
                try {
                    canonicalPath = new File(absolutePath).getCanonicalPath();
                } catch (IOException e) {
                    throw .invalidSendFilePath(absolutePath);
                }
                System.getSecurityManager().checkRead(canonicalPath);
                .setSendfilePath(absolutePath);
                .setSendfileStart(start);
                .setSendfileEnd(end);
            }
        } else {
            if (absolutePath != null) {
                .setSendfilePath(absolutePath);
                .setSendfileStart(start);
                .setSendfileEnd(end);
            } else {
                CacheEntry cacheEntry = 
                    ((ProxyDirContext.getContext().getResources()).lookupCache(path);
                if (cacheEntry.exists && cacheEntry.resource != null && (end > start)
                        && cacheEntry.attributes.getCanonicalPath() != null) {
                    .setSendfilePath(cacheEntry.attributes.getCanonicalPath());
                    .setSendfileStart(start);
                    .setSendfileEnd(end);
                }
            }
        }
        .setBytesWritten(end - start);
        // Cause the response to be finished (from the application perspective)
        setSuspended(true);
    }


    
Set the specified date header to the specified value.

Parameters:
name Name of the header to set
value Date value to be set
    public void setDateHeader(String namelong value) {
        if (name == null || name.length() == 0) {
            return;
        }
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if () {
            return;
        }
        if ( == null) {
                                          .);
            .setTimeZone(TimeZone.getTimeZone("GMT"));
        }
        setHeader(name, FastHttpDateFormat.formatDate(value));
    }


    
Set the specified header to the specified value.

Parameters:
name Name of the header to set
value Value to be set
    public void setHeader(String nameString value) {
        if (name == null || name.length() == 0 || value == null) {
            return;
        }
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return;
        .setHeader(namevalue);
    }


    
Set the specified integer header to the specified value.

Parameters:
name Name of the header to set
value Integer value to be set
    public void setIntHeader(String nameint value) {
        if (name == null || name.length() == 0) {
            return;
        }
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return;
        setHeader(name"" + value);
    }


    
Set the HTTP status to be returned with this response.

Parameters:
status The new HTTP status
    public void setStatus(int status) {
        setStatus(statusnull);
    }


    
Set the HTTP status and message to be returned with this response.

Deprecated:
As of Version 2.1 of the Java Servlet API, this method has been deprecated due to the ambiguous meaning of the message parameter.
Parameters:
status The new HTTP status
message The associated text message
    public void setStatus(int statusString message) {
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return;
        .setStatus(status);
        .setMessage(message);
    }
    public void setContentLengthLong(long length) {
        if (isCommitted())
            return;
        // Ignore any call from an included servlet
        if ()
            return;
        if ()
    &n