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