1/*2 * $Id: JspWriterResponse.java 736275 2009-01-21 09:58:20Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */21package org.apache.tiles.jsp.context;
2223import javax.servlet.http.HttpServletResponseWrapper;
24import javax.servlet.http.HttpServletResponse;
25import javax.servlet.jsp.PageContext;
26import java.io.PrintWriter;
27import java.io.IOException;
282930/***31 * It works as an {@link HttpServletResponse} by wrapping a32 * {@link javax.servlet.jsp.JspWriter} around a {@link PrintWriter}.33 *34 * @version $Rev: 736275 $ $Date: 2009-01-21 10:58:20 +0100 (mer, 21 gen 2009) $35 */36publicclassJspWriterResponseextends HttpServletResponseWrapper {
3738/***39 * The page context to use.40 */41private PageContext context;
4243/***44 * The created print writer.45 */46private PrintWriter writer;
4748/***49 * Constructor.50 *51 * @param pageContext The page context to use.52 */53publicJspWriterResponse(PageContext pageContext) {
54super((HttpServletResponse) pageContext.getResponse());
55this.context = pageContext;
56 }
575859/*** {@inheritDoc} */60public PrintWriter getWriter() throws IOException {
61if (writer == null) {
62 writer = newJspPrintWriterAdapter(context.getOut());
63 }
64return writer;
65 }
66 }