1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.tiles.servlet.context;
23
24 import javax.servlet.http.HttpServletRequest;
25
26
27 /***
28 * Utilities for Tiles servlet support.
29 *
30 * @version $Rev: 619574 $ $Date: 2008-02-07 20:09:33 +0100 (Thu, 07 Feb 2008) $
31 * @since 2.0.6
32 */
33 public final class ServletUtil {
34
35 /***
36 * Name of the attribute used to store the force-include option.
37 * @since 2.0.6
38 */
39 public static final String FORCE_INCLUDE_ATTRIBUTE_NAME =
40 "org.apache.tiles.servlet.context.ServletTilesRequestContext.FORCE_INCLUDE";
41
42 /***
43 * Private constructor to avoid instantiation.
44 */
45 private ServletUtil() {
46 }
47
48 /***
49 * Returns true if forced include of the result is needed.
50 *
51 * @param request The HTTP request.
52 * @return If <code>true</code> the include operation must be forced.
53 * @since 2.0.6
54 */
55 public static boolean isForceInclude(HttpServletRequest request) {
56 Boolean retValue = (Boolean) request
57 .getAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME);
58 return retValue != null && retValue.booleanValue();
59 }
60
61 /***
62 * Sets the option that enables the forced include of the response.
63 *
64 * @param request The HTTP request.
65 * @param forceInclude If <code>true</code> the include operation must be
66 * forced.
67 * @since 2.0.6
68 */
69 public static void setForceInclude(HttpServletRequest request,
70 boolean forceInclude) {
71 Boolean retValue = Boolean.valueOf(forceInclude);
72 request.setAttribute(
73 ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME,
74 retValue);
75 }
76 }