001: /*
002: * Copyright 2005 jWic group (http://www.jwic.de)
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: * de.jwic.renderer.jsp.HttpServletResponseFacade
017: * Created on 04.12.2005
018: * $Id: HttpServletResponseFacade.java,v 1.1 2006/01/16 08:31:13 lordsam Exp $
019: */
020: package de.jwic.renderer.jsp;
021:
022: import java.io.IOException;
023: import java.io.PrintWriter;
024: import java.util.Locale;
025:
026: import javax.servlet.ServletOutputStream;
027: import javax.servlet.http.Cookie;
028: import javax.servlet.http.HttpServletResponse;
029:
030: /**
031: * Used as a facade when including JSP pages to force the jsp page to write into the
032: * specified printWriter. This is required to allow ajax based updates.
033: *
034: * @author Florian Lippisch
035: * @version $Revision: 1.1 $
036: */
037: public class HttpServletResponseFacade implements HttpServletResponse {
038:
039: private HttpServletResponse response;
040: private PrintWriter writer;
041:
042: /**
043: * Constructs a new facade object.
044: * @param response
045: * @param writer
046: */
047: public HttpServletResponseFacade(HttpServletResponse response,
048: PrintWriter writer) {
049:
050: this .response = response;
051: this .writer = writer;
052:
053: }
054:
055: /* (non-Javadoc)
056: * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie)
057: */
058: public void addCookie(Cookie cookie) {
059: response.addCookie(cookie);
060: }
061:
062: /* (non-Javadoc)
063: * @see javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String)
064: */
065: public boolean containsHeader(String header) {
066: return response.containsHeader(header);
067: }
068:
069: /* (non-Javadoc)
070: * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String)
071: */
072: public String encodeURL(String url) {
073: return response.encodeURL(url);
074: }
075:
076: /* (non-Javadoc)
077: * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String)
078: */
079: public String encodeRedirectURL(String url) {
080: return response.encodeRedirectURL(url);
081: }
082:
083: /**
084: * @see javax.servlet.http.HttpServletResponse#encodeUrl(java.lang.String)
085: * @deprecated
086: */
087: public String encodeUrl(String url) {
088: return response.encodeUrl(url);
089: }
090:
091: /**
092: * @see javax.servlet.http.HttpServletResponse#encodeRedirectUrl(java.lang.String)
093: * @deprecated
094: */
095: public String encodeRedirectUrl(String url) {
096: return response.encodeRedirectUrl(url);
097: }
098:
099: /* (non-Javadoc)
100: * @see javax.servlet.http.HttpServletResponse#sendError(int, java.lang.String)
101: */
102: public void sendError(int code, String msg) throws IOException {
103: response.sendError(code, msg);
104: }
105:
106: /* (non-Javadoc)
107: * @see javax.servlet.http.HttpServletResponse#sendError(int)
108: */
109: public void sendError(int code) throws IOException {
110: response.sendError(code);
111: }
112:
113: /* (non-Javadoc)
114: * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String)
115: */
116: public void sendRedirect(String arg0) throws IOException {
117: throw new IOException(
118: "Redirect is not allowed in a JSP template.");
119: }
120:
121: /* (non-Javadoc)
122: * @see javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String, long)
123: */
124: public void setDateHeader(String arg0, long arg1) {
125: // ignore
126: }
127:
128: /* (non-Javadoc)
129: * @see javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String, long)
130: */
131: public void addDateHeader(String arg0, long arg1) {
132: // ignore
133: }
134:
135: /* (non-Javadoc)
136: * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String)
137: */
138: public void setHeader(String arg0, String arg1) {
139: // ignore
140: }
141:
142: /* (non-Javadoc)
143: * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String)
144: */
145: public void addHeader(String arg0, String arg1) {
146: // ignore
147: }
148:
149: /* (non-Javadoc)
150: * @see javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String, int)
151: */
152: public void setIntHeader(String arg0, int arg1) {
153: // ignore
154: }
155:
156: /* (non-Javadoc)
157: * @see javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String, int)
158: */
159: public void addIntHeader(String arg0, int arg1) {
160: // ignore
161: }
162:
163: /* (non-Javadoc)
164: * @see javax.servlet.http.HttpServletResponse#setStatus(int)
165: */
166: public void setStatus(int arg0) {
167: // ignore
168: }
169:
170: /* (non-Javadoc)
171: * @see javax.servlet.http.HttpServletResponse#setStatus(int, java.lang.String)
172: */
173: public void setStatus(int arg0, String arg1) {
174: // ignore
175: }
176:
177: /* (non-Javadoc)
178: * @see javax.servlet.ServletResponse#getCharacterEncoding()
179: */
180: public String getCharacterEncoding() {
181: return response.getCharacterEncoding();
182: }
183:
184: /* (non-Javadoc)
185: * @see javax.servlet.ServletResponse#getContentType()
186: */
187: public String getContentType() {
188: return response.getContentType();
189: }
190:
191: /* (non-Javadoc)
192: * @see javax.servlet.ServletResponse#getOutputStream()
193: */
194: public ServletOutputStream getOutputStream() throws IOException {
195: throw new IOException("JSP Templates must use a writer!");
196: }
197:
198: /* (non-Javadoc)
199: * @see javax.servlet.ServletResponse#getWriter()
200: */
201: public PrintWriter getWriter() throws IOException {
202: return writer;
203: }
204:
205: /* (non-Javadoc)
206: * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
207: */
208: public void setCharacterEncoding(String arg0) {
209: // ignore
210: }
211:
212: /* (non-Javadoc)
213: * @see javax.servlet.ServletResponse#setContentLength(int)
214: */
215: public void setContentLength(int arg0) {
216: // ignore
217: }
218:
219: /* (non-Javadoc)
220: * @see javax.servlet.ServletResponse#setContentType(java.lang.String)
221: */
222: public void setContentType(String arg0) {
223: // ignore
224: }
225:
226: /* (non-Javadoc)
227: * @see javax.servlet.ServletResponse#setBufferSize(int)
228: */
229: public void setBufferSize(int arg0) {
230: // ignore
231: }
232:
233: /* (non-Javadoc)
234: * @see javax.servlet.ServletResponse#getBufferSize()
235: */
236: public int getBufferSize() {
237: return response.getBufferSize();
238: }
239:
240: /* (non-Javadoc)
241: * @see javax.servlet.ServletResponse#flushBuffer()
242: */
243: public void flushBuffer() throws IOException {
244: // TODO Auto-generated method stub
245:
246: }
247:
248: /* (non-Javadoc)
249: * @see javax.servlet.ServletResponse#resetBuffer()
250: */
251: public void resetBuffer() {
252: // ignore
253: }
254:
255: /* (non-Javadoc)
256: * @see javax.servlet.ServletResponse#isCommitted()
257: */
258: public boolean isCommitted() {
259: return response.isCommitted();
260: }
261:
262: /* (non-Javadoc)
263: * @see javax.servlet.ServletResponse#reset()
264: */
265: public void reset() {
266: // ignore
267: }
268:
269: /* (non-Javadoc)
270: * @see javax.servlet.ServletResponse#setLocale(java.util.Locale)
271: */
272: public void setLocale(Locale arg0) {
273: // ignore
274: }
275:
276: /* (non-Javadoc)
277: * @see javax.servlet.ServletResponse#getLocale()
278: */
279: public Locale getLocale() {
280: return response.getLocale();
281: }
282:
283: }
|