01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal;
07:
08: import java.io.IOException;
09: import java.io.PrintWriter;
10:
11: import javax.servlet.ServletOutputStream;
12: import javax.servlet.http.HttpServletResponse;
13: import javax.servlet.http.HttpServletResponseWrapper;
14:
15: import org.jasig.portal.utils.SubstitutionWriter;
16:
17: /**
18: * Replaces tags in the markup with the tag for the current request.
19: * @author Peter Kharchenko, pkharchenko@unicon.net
20: * @version $Revision: 34817 $
21: */
22: public class ResponseSubstitutionWrapper extends
23: HttpServletResponseWrapper {
24: protected String sessionTag;
25: protected String newTag;
26:
27: public ResponseSubstitutionWrapper(HttpServletResponse res,
28: String sessionTag, String newTag) {
29: super (res);
30: this .sessionTag = sessionTag;
31: this .newTag = newTag;
32: }
33:
34: public ServletOutputStream getOutputStream() throws IOException {
35: return getResponse().getOutputStream();
36: }
37:
38: public PrintWriter getWriter() throws IOException {
39: return new PrintWriter(new SubstitutionWriter(getResponse()
40: .getWriter(), sessionTag.toCharArray(), newTag
41: .toCharArray(), this.getBufferSize()));
42: }
43:
44: }
|