1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package javax.servlet.http;
17
18 import javax.servlet.ServletRequestWrapper;
19 import java.util.Enumeration;
20
21 /**
22 *
23 * Provides a convenient implementation of the HttpServletRequest interface that
24 * can be subclassed by developers wishing to adapt the request to a Servlet.
25 * This class implements the Wrapper or Decorator pattern. Methods default to
26 * calling through to the wrapped request object.
27 *
28 *
29 * @see javax.servlet.http.HttpServletRequest
30 * @since v 2.3
31 *
32 */
33
34
35 public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest {
36
37 /**
38 * Constructs a request object wrapping the given request.
39 * @throws java.lang.IllegalArgumentException if the request is null
40 */
41 public HttpServletRequestWrapper(HttpServletRequest request) {
42 super(request);
43 }
44
45 private HttpServletRequest _getHttpServletRequest() {
46 return (HttpServletRequest) super.getRequest();
47 }
48
49 /**
50 * The default behavior of this method is to return getAuthType()
51 * on the wrapped request object.
52 */
53
54 public String getAuthType() {
55 return this._getHttpServletRequest().getAuthType();
56 }
57
58 /**
59 * The default behavior of this method is to return getCookies()
60 * on the wrapped request object.
61 */
62 public Cookie[] getCookies() {
63 return this._getHttpServletRequest().getCookies();
64 }
65
66 /**
67 * The default behavior of this method is to return getDateHeader(String name)
68 * on the wrapped request object.
69 */
70 public long getDateHeader(String name) {
71 return this._getHttpServletRequest().getDateHeader(name);
72 }
73
74 /**
75 * The default behavior of this method is to return getHeader(String name)
76 * on the wrapped request object.
77 */
78 public String getHeader(String name) {
79 return this._getHttpServletRequest().getHeader(name);
80 }
81
82 /**
83 * The default behavior of this method is to return getHeaders(String name)
84 * on the wrapped request object.
85 */
86 public Enumeration getHeaders(String name) {
87 return this._getHttpServletRequest().getHeaders(name);
88 }
89
90 /**
91 * The default behavior of this method is to return getHeaderNames()
92 * on the wrapped request object.
93 */
94
95 public Enumeration getHeaderNames() {
96 return this._getHttpServletRequest().getHeaderNames();
97 }
98
99 /**
100 * The default behavior of this method is to return getIntHeader(String name)
101 * on the wrapped request object.
102 */
103
104 public int getIntHeader(String name) {
105 return this._getHttpServletRequest().getIntHeader(name);
106 }
107
108 /**
109 * The default behavior of this method is to return getMethod()
110 * on the wrapped request object.
111 */
112 public String getMethod() {
113 return this._getHttpServletRequest().getMethod();
114 }
115
116 /**
117 * The default behavior of this method is to return getPathInfo()
118 * on the wrapped request object.
119 */
120 public String getPathInfo() {
121 return this._getHttpServletRequest().getPathInfo();
122 }
123
124 /**
125 * The default behavior of this method is to return getPathTranslated()
126 * on the wrapped request object.
127 */
128
129 public String getPathTranslated() {
130 return this._getHttpServletRequest().getPathTranslated();
131 }
132
133 /**
134 * The default behavior of this method is to return getContextPath()
135 * on the wrapped request object.
136 */
137 public String getContextPath() {
138 return this._getHttpServletRequest().getContextPath();
139 }
140
141 /**
142 * The default behavior of this method is to return getQueryString()
143 * on the wrapped request object.
144 */
145 public String getQueryString() {
146 return this._getHttpServletRequest().getQueryString();
147 }
148
149 /**
150 * The default behavior of this method is to return getRemoteUser()
151 * on the wrapped request object.
152 */
153 public String getRemoteUser() {
154 return this._getHttpServletRequest().getRemoteUser();
155 }
156
157
158 /**
159 * The default behavior of this method is to return isUserInRole(String role)
160 * on the wrapped request object.
161 */
162 public boolean isUserInRole(String role) {
163 return this._getHttpServletRequest().isUserInRole(role);
164 }
165
166
167
168 /**
169 * The default behavior of this method is to return getUserPrincipal()
170 * on the wrapped request object.
171 */
172 public java.security.Principal getUserPrincipal() {
173 return this._getHttpServletRequest().getUserPrincipal();
174 }
175
176
177 /**
178 * The default behavior of this method is to return getRequestedSessionId()
179 * on the wrapped request object.
180 */
181 public String getRequestedSessionId() {
182 return this._getHttpServletRequest().getRequestedSessionId();
183 }
184
185 /**
186 * The default behavior of this method is to return getRequestURI()
187 * on the wrapped request object.
188 */
189 public String getRequestURI() {
190 return this._getHttpServletRequest().getRequestURI();
191 }
192 /**
193 * The default behavior of this method is to return getRequestURL()
194 * on the wrapped request object.
195 */
196 public StringBuffer getRequestURL() {
197 return this._getHttpServletRequest().getRequestURL();
198 }
199
200
201 /**
202 * The default behavior of this method is to return getServletPath()
203 * on the wrapped request object.
204 */
205 public String getServletPath() {
206 return this._getHttpServletRequest().getServletPath();
207 }
208
209
210 /**
211 * The default behavior of this method is to return getSession(boolean create)
212 * on the wrapped request object.
213 */
214 public HttpSession getSession(boolean create) {
215 return this._getHttpServletRequest().getSession(create);
216 }
217
218 /**
219 * The default behavior of this method is to return getSession()
220 * on the wrapped request object.
221 */
222 public HttpSession getSession() {
223 return this._getHttpServletRequest().getSession();
224 }
225
226 /**
227 * The default behavior of this method is to return isRequestedSessionIdValid()
228 * on the wrapped request object.
229 */
230
231 public boolean isRequestedSessionIdValid() {
232 return this._getHttpServletRequest().isRequestedSessionIdValid();
233 }
234
235
236 /**
237 * The default behavior of this method is to return isRequestedSessionIdFromCookie()
238 * on the wrapped request object.
239 */
240 public boolean isRequestedSessionIdFromCookie() {
241 return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
242 }
243
244 /**
245 * The default behavior of this method is to return isRequestedSessionIdFromURL()
246 * on the wrapped request object.
247 */
248 public boolean isRequestedSessionIdFromURL() {
249 return this._getHttpServletRequest().isRequestedSessionIdFromURL();
250 }
251
252 /**
253 * The default behavior of this method is to return isRequestedSessionIdFromUrl()
254 * on the wrapped request object.
255 */
256 public boolean isRequestedSessionIdFromUrl() {
257 return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
258 }
259
260
261
262 }