KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > server > AbstractHttpServletRequestWrapper23


1 /*
2  * ========================================================================
3  *
4  * Copyright 2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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 JavaDoc;
23
24 import java.util.Map JavaDoc;
25
26 import javax.servlet.http.HttpServletRequest JavaDoc;
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,v 1.1 2004/05/22 16:39:34 vmassol Exp $
36  */

37 public abstract class AbstractHttpServletRequestWrapper23
38     extends AbstractHttpServletRequestWrapper
39 {
40     /**
41      * Construct a {@link HttpServletRequest} instance that delegates
42      * it's method calls to the request object passed as parameter and that
43      * uses the URL passed as parameter to simulate a URL from which the
44      * request would come from.
45      *
46      * @param theRequest the real HTTP request
47      * @param theURL the URL to simulate or <code>null</code> if none
48      */

49     public AbstractHttpServletRequestWrapper23(HttpServletRequest JavaDoc theRequest,
50         ServletURL theURL)
51     {
52         super(theRequest, theURL);
53     }
54
55     // Unmodified methods --------------------------------------------------
56

57     /**
58      * @return the URL from the simulated URL or the real URL
59      * if a simulation URL has not been defined.
60      * @see HttpServletRequest#getRequestURL()
61      */

62     public StringBuffer JavaDoc getRequestURL()
63     {
64         StringBuffer JavaDoc result;
65
66         if (this.url != null)
67         {
68             result = new StringBuffer JavaDoc(this.url.getProtocol() + "://"
69                 + getServerName() + ":" + getServerPort()
70                 + getRequestURI());
71         }
72         else
73         {
74             result = this.request.getRequestURL();
75         }
76
77         return result;
78     }
79
80     /**
81      * @see HttpServletRequest#setCharacterEncoding(String)
82      */

83     public void setCharacterEncoding(String JavaDoc theEnvironment)
84         throws UnsupportedEncodingException JavaDoc
85     {
86         this.request.setCharacterEncoding(theEnvironment);
87     }
88
89     /**
90      * @see HttpServletRequest#getParameterMap()
91      */

92     public Map JavaDoc getParameterMap()
93     {
94         return this.request.getParameterMap();
95     }
96 }
97
Popular Tags