Home » tiles-2.2.1-src » org.apache.tiles.jsp » context » [javadoc | source]

    1   /*
    2    * $Id: JspWriterResponse.java 736275 2009-01-21 09:58:20Z apetrelli $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
   10    * with the License.  You may obtain a copy of the License at
   11    *
   12    * http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing,
   15    * software distributed under the License is distributed on an
   16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   17    * KIND, either express or implied.  See the License for the
   18    * specific language governing permissions and limitations
   19    * under the License.
   20    */
   21   package org.apache.tiles.jsp.context;
   22   
   23   import javax.servlet.http.HttpServletResponseWrapper;
   24   import javax.servlet.http.HttpServletResponse;
   25   import javax.servlet.jsp.PageContext;
   26   import java.io.PrintWriter;
   27   import java.io.IOException;
   28   
   29   
   30   /**
   31    * It works as an {@link HttpServletResponse} by wrapping a
   32    * {@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    */
   36   public class JspWriterResponse extends HttpServletResponseWrapper {
   37   
   38       /**
   39        * The page context to use.
   40        */
   41       private PageContext context;
   42   
   43       /**
   44        * The created print writer.
   45        */
   46       private PrintWriter writer;
   47   
   48       /**
   49        * Constructor.
   50        *
   51        * @param pageContext The page context to use.
   52        */
   53       public JspWriterResponse(PageContext pageContext) {
   54           super((HttpServletResponse) pageContext.getResponse());
   55           this.context = pageContext;
   56       }
   57   
   58   
   59       /** {@inheritDoc} */
   60       public PrintWriter getWriter() throws IOException {
   61           if (writer == null) {
   62               writer = new JspPrintWriterAdapter(context.getOut());
   63           }
   64           return writer;
   65       }
   66   }

Home » tiles-2.2.1-src » org.apache.tiles.jsp » context » [javadoc | source]