1 /*
2 * $Id: JspUtil.java 619574 2008-02-07 19:09:33Z 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 org.apache.tiles.servlet.context.ServletUtil;
24
25 import javax.servlet.jsp.PageContext;
26
27 /**
28 * Utility class for working within a Jsp environment.
29 *
30 * @version $Rev: 619574 $ $Date: 2008-02-07 20:09:33 +0100 (Thu, 07 Feb 2008) $
31 */
32 public final class JspUtil {
33
34 /**
35 * Constructor, private to avoid instantiation.
36 */
37 private JspUtil() {
38 }
39
40 /**
41 * Returns true if forced include of the result is needed.
42 *
43 * @param context The page context.
44 * @return If <code>true</code> the include operation must be forced.
45 * @since 2.0.6
46 */
47 public static boolean isForceInclude(PageContext context) {
48 Boolean retValue = (Boolean) context.getAttribute(
49 ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME,
50 PageContext.REQUEST_SCOPE);
51 return retValue != null && retValue.booleanValue();
52 }
53
54 /**
55 * Sets the option that enables the forced include of the response.
56 *
57 * @param context The page context.
58 * @param forceInclude If <code>true</code> the include operation must be
59 * forced.
60 * @since 2.0.6
61 */
62 public static void setForceInclude(PageContext context, boolean forceInclude) {
63 Boolean retValue = Boolean.valueOf(forceInclude);
64 context.setAttribute(
65 ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME,
66 retValue, PageContext.REQUEST_SCOPE);
67 }
68 }