1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jxpath.servlet;
17
18 import java.util.Enumeration;
19
20 import javax.servlet.jsp.PageContext;
21
22 /***
23 * A lightweight wrapper for PageContext that restricts access
24 * to attributes of the "page" scope. This object is needed so that
25 * XPath "foo" would lookup the attribute "foo" in all scopes, while
26 * "$page/foo" would only look in the "page" scope.
27 *
28 * @author Dmitri Plotnikov
29 * @version $Revision: 1.5 $ $Date: 2004/02/29 14:17:40 $
30 */
31 public class PageScopeContext {
32 private PageContext pageContext;
33
34 public PageScopeContext(PageContext pageContext) {
35 this.pageContext = pageContext;
36 }
37
38 /***
39 * Returns attributes of the pageContext declared in the "page" scope.
40 */
41 public Enumeration getAttributeNames() {
42 return pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
43 }
44
45 public Object getAttribute(String attribute) {
46 return pageContext.getAttribute(attribute, PageContext.PAGE_SCOPE);
47 }
48
49 public void setAttribute(String attribute, Object value) {
50 pageContext.setAttribute(attribute, value, PageContext.PAGE_SCOPE);
51 }
52 }