1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts.taglib.bean;
22
23 import org.apache.struts.taglib.TagUtils;
24 import org.apache.struts.util.MessageResources;
25
26 import javax.servlet.jsp.JspException;
27 import javax.servlet.jsp.tagext.TagSupport;
28
29
30
31
32
33
34
35
36 public class PageTag extends TagSupport {
37
38
39
40 protected static MessageResources messages =
41 MessageResources.getMessageResources(
42 "org.apache.struts.taglib.bean.LocalStrings");
43
44
45
46
47
48
49
50 protected String id = null;
51
52
53
54
55 protected String property = null;
56
57 public String getId() {
58 return (this.id);
59 }
60
61 public void setId(String id) {
62 this.id = id;
63 }
64
65 public String getProperty() {
66 return (this.property);
67 }
68
69 public void setProperty(String property) {
70 this.property = property;
71 }
72
73
74
75
76
77
78
79
80
81 public int doStartTag() throws JspException {
82
83 Object object = null;
84
85 if ("application".equalsIgnoreCase(property)) {
86 object = pageContext.getServletContext();
87 } else if ("config".equalsIgnoreCase(property)) {
88 object = pageContext.getServletConfig();
89 } else if ("request".equalsIgnoreCase(property)) {
90 object = pageContext.getRequest();
91 } else if ("response".equalsIgnoreCase(property)) {
92 object = pageContext.getResponse();
93 } else if ("session".equalsIgnoreCase(property)) {
94 object = pageContext.getSession();
95 } else {
96 JspException e =
97 new JspException(messages.getMessage("page.selector", property));
98
99 TagUtils.getInstance().saveException(pageContext, e);
100 throw e;
101 }
102
103
104 pageContext.setAttribute(id, object);
105
106 return (SKIP_BODY);
107 }
108
109
110
111
112 public void release() {
113 super.release();
114 id = null;
115 property = null;
116 }
117 }