01: /*
02: * ========================================================================
03: *
04: * Copyright 2004 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * ========================================================================
19: */
20: package org.apache.cactus.server;
21:
22: import java.io.UnsupportedEncodingException;
23:
24: import java.util.Map;
25:
26: import javax.servlet.http.HttpServletRequest;
27:
28: import org.apache.cactus.ServletURL;
29:
30: /**
31: * Extends {@link AbstractHttpServletRequestWrapper} by adding the new methods
32: * of the Servlet 2.3 API specifications.
33: *
34: * @see AbstractHttpServletRequestWrapper
35: * @version $Id: AbstractHttpServletRequestWrapper23.java 238993 2004-05-22 16:39:34Z vmassol $
36: */
37: public abstract class AbstractHttpServletRequestWrapper23 extends
38: AbstractHttpServletRequestWrapper {
39: /**
40: * Construct a {@link HttpServletRequest} instance that delegates
41: * it's method calls to the request object passed as parameter and that
42: * uses the URL passed as parameter to simulate a URL from which the
43: * request would come from.
44: *
45: * @param theRequest the real HTTP request
46: * @param theURL the URL to simulate or <code>null</code> if none
47: */
48: public AbstractHttpServletRequestWrapper23(
49: HttpServletRequest theRequest, ServletURL theURL) {
50: super (theRequest, theURL);
51: }
52:
53: // Unmodified methods --------------------------------------------------
54:
55: /**
56: * @return the URL from the simulated URL or the real URL
57: * if a simulation URL has not been defined.
58: * @see HttpServletRequest#getRequestURL()
59: */
60: public StringBuffer getRequestURL() {
61: StringBuffer result;
62:
63: if (this .url != null) {
64: result = new StringBuffer(this .url.getProtocol() + "://"
65: + getServerName() + ":" + getServerPort()
66: + getRequestURI());
67: } else {
68: result = this .request.getRequestURL();
69: }
70:
71: return result;
72: }
73:
74: /**
75: * @see HttpServletRequest#setCharacterEncoding(String)
76: */
77: public void setCharacterEncoding(String theEnvironment)
78: throws UnsupportedEncodingException {
79: this .request.setCharacterEncoding(theEnvironment);
80: }
81:
82: /**
83: * @see HttpServletRequest#getParameterMap()
84: */
85: public Map getParameterMap() {
86: return this.request.getParameterMap();
87: }
88: }
|