01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13: package com.sun.portal.portletappengine;
14:
15: import java.io.CharArrayWriter;
16: import java.io.PrintWriter;
17:
18: import javax.servlet.http.HttpServletResponse;
19: import javax.servlet.http.HttpServletResponseWrapper;
20:
21: /*
22: * This class is a wrapper of the http servlet response for outputing
23: * error content to the portlet window.
24: */
25: public class ErrorResponse extends HttpServletResponseWrapper {
26:
27: private CharArrayWriter _buffer = new CharArrayWriter();
28: private PrintWriter _writer = new PrintWriter(_buffer);
29:
30: // Constructor
31: public ErrorResponse(HttpServletResponse res) {
32: super (res);
33: }
34:
35: /**
36: * Overrides the <code>getWriter</code>() method of the
37: * <code>HttpServletResponse</code> and returns the
38: * <code>PrintWriter</code> that is instantiated from a
39: * <code>CharArrayWritter</code>.
40: * <P>
41: * @return A <code>PrintWriter</code>
42: */
43: public PrintWriter getWriter() {
44: return _writer;
45: }
46:
47: /**
48: * Returns the content of the error page as a <code>StringBuffer</code>.
49: * <P>
50: * @return A <code>StringBuffer</code>
51: */
52: public StringBuffer getBuffer() {
53: return new StringBuffer(_buffer.toString());
54: }
55: }
|