001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina;
018:
019: import java.io.IOException;
020: import java.io.OutputStream;
021: import java.io.PrintWriter;
022:
023: import javax.servlet.ServletOutputStream;
024: import javax.servlet.ServletResponse;
025:
026: /**
027: * A <b>Response</b> is the Catalina-internal facade for a
028: * <code>ServletResponse</code> that is to be produced,
029: * based on the processing of a corresponding <code>Request</code>.
030: *
031: * @author Craig R. McClanahan
032: * @version $Revision: 1.4 $ $Date: 2004/02/27 14:58:39 $
033: */
034:
035: public interface Response {
036:
037: // ------------------------------------------------------------- Properties
038:
039: /**
040: * Return the Connector through which this Response is returned.
041: */
042: public Connector getConnector();
043:
044: /**
045: * Set the Connector through which this Response is returned.
046: *
047: * @param connector The new connector
048: */
049: public void setConnector(Connector connector);
050:
051: /**
052: * Return the number of bytes actually written to the output stream.
053: */
054: public int getContentCount();
055:
056: /**
057: * Return the Context with which this Response is associated.
058: */
059: public Context getContext();
060:
061: /**
062: * Set the Context with which this Response is associated. This should
063: * be called as soon as the appropriate Context is identified.
064: *
065: * @param context The associated Context
066: */
067: public void setContext(Context context);
068:
069: /**
070: * Set the application commit flag.
071: *
072: * @param appCommitted The new application committed flag value
073: */
074: public void setAppCommitted(boolean appCommitted);
075:
076: /**
077: * Application commit flag accessor.
078: */
079: public boolean isAppCommitted();
080:
081: /**
082: * Return the "processing inside an include" flag.
083: */
084: public boolean getIncluded();
085:
086: /**
087: * Set the "processing inside an include" flag.
088: *
089: * @param included <code>true</code> if we are currently inside a
090: * RequestDispatcher.include(), else <code>false</code>
091: */
092: public void setIncluded(boolean included);
093:
094: /**
095: * Return descriptive information about this Response implementation and
096: * the corresponding version number, in the format
097: * <code><description>/<version></code>.
098: */
099: public String getInfo();
100:
101: /**
102: * Return the Request with which this Response is associated.
103: */
104: public Request getRequest();
105:
106: /**
107: * Set the Request with which this Response is associated.
108: *
109: * @param request The new associated request
110: */
111: public void setRequest(Request request);
112:
113: /**
114: * Return the <code>ServletResponse</code> for which this object
115: * is the facade.
116: */
117: public ServletResponse getResponse();
118:
119: /**
120: * Return the output stream associated with this Response.
121: */
122: public OutputStream getStream();
123:
124: /**
125: * Set the output stream associated with this Response.
126: *
127: * @param stream The new output stream
128: */
129: public void setStream(OutputStream stream);
130:
131: /**
132: * Set the suspended flag.
133: *
134: * @param suspended The new suspended flag value
135: */
136: public void setSuspended(boolean suspended);
137:
138: /**
139: * Suspended flag accessor.
140: */
141: public boolean isSuspended();
142:
143: /**
144: * Set the error flag.
145: */
146: public void setError();
147:
148: /**
149: * Error flag accessor.
150: */
151: public boolean isError();
152:
153: // --------------------------------------------------------- Public Methods
154:
155: /**
156: * Create and return a ServletOutputStream to write the content
157: * associated with this Response.
158: *
159: * @exception IOException if an input/output error occurs
160: */
161: public ServletOutputStream createOutputStream() throws IOException;
162:
163: /**
164: * Perform whatever actions are required to flush and close the output
165: * stream or writer, in a single operation.
166: *
167: * @exception IOException if an input/output error occurs
168: */
169: public void finishResponse() throws IOException;
170:
171: /**
172: * Return the content length that was set or calculated for this Response.
173: */
174: public int getContentLength();
175:
176: /**
177: * Return the content type that was set or calculated for this response,
178: * or <code>null</code> if no content type was set.
179: */
180: public String getContentType();
181:
182: /**
183: * Return a PrintWriter that can be used to render error messages,
184: * regardless of whether a stream or writer has already been acquired.
185: *
186: * @return Writer which can be used for error reports. If the response is
187: * not an error report returned using sendError or triggered by an
188: * unexpected exception thrown during the servlet processing
189: * (and only in that case), null will be returned if the response stream
190: * has already been used.
191: *
192: * @exception IOException if an input/output error occurs
193: */
194: public PrintWriter getReporter() throws IOException;
195:
196: /**
197: * Release all object references, and initialize instance variables, in
198: * preparation for reuse of this object.
199: */
200: public void recycle();
201:
202: /**
203: * Reset the data buffer but not any status or header information.
204: */
205: public void resetBuffer();
206:
207: /**
208: * Send an acknowledgment of a request.
209: *
210: * @exception IOException if an input/output error occurs
211: */
212: public void sendAcknowledgement() throws IOException;
213:
214: }
|