001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.jsp;
018:
019: import java.io.BufferedReader;
020: import java.io.IOException;
021: import java.security.Principal;
022: import java.util.Enumeration;
023: import java.util.Locale;
024:
025: import javax.servlet.RequestDispatcher;
026: import javax.servlet.ServletInputStream;
027: import javax.servlet.http.Cookie;
028: import javax.servlet.http.HttpServletRequest;
029: import javax.servlet.http.HttpSession;
030:
031: /**
032: * Stub implementation of HttpServletRequest.
033: */
034: public class JSPEngineServletRequest implements HttpServletRequest {
035:
036: /** The servlet include path. */
037: private static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
038: /** The servlet request uri, needed for Resin. */
039: private static final String INC_REQUEST_URI = "javax.servlet.include.request_uri";
040:
041: private final HttpServletRequest request;
042: private final String jspFile;
043:
044: public JSPEngineServletRequest(HttpServletRequest request,
045: String jspFile) {
046: this .request = request;
047: this .jspFile = jspFile;
048: }
049:
050: public String getAuthType() {
051: return request.getAuthType();
052: }
053:
054: public Cookie[] getCookies() {
055: return request.getCookies();
056: }
057:
058: public long getDateHeader(String s) {
059: return request.getDateHeader(s);
060: }
061:
062: public String getHeader(String s) {
063: return request.getHeader(s);
064: }
065:
066: public Enumeration getHeaders(String s) {
067: return request.getHeaders(s);
068: }
069:
070: public Enumeration getHeaderNames() {
071: return request.getHeaderNames();
072: }
073:
074: public int getIntHeader(String s) {
075: return request.getIntHeader(s);
076: }
077:
078: public String getMethod() {
079: return request.getMethod();
080: }
081:
082: public String getPathInfo() {
083: return request.getPathInfo();
084: }
085:
086: public String getPathTranslated() {
087: return request.getPathTranslated();
088: }
089:
090: public String getContextPath() {
091: return request.getContextPath();
092: }
093:
094: public String getQueryString() {
095: return request.getQueryString();
096: }
097:
098: public String getRemoteUser() {
099: return request.getRemoteUser();
100: }
101:
102: public boolean isUserInRole(String s) {
103: return request.isUserInRole(s);
104: }
105:
106: public Principal getUserPrincipal() {
107: return request.getUserPrincipal();
108: }
109:
110: public String getRequestedSessionId() {
111: return request.getRequestedSessionId();
112: }
113:
114: public String getRequestURI() {
115: return request.getRequestURI();
116: }
117:
118: public String getServletPath() {
119: return request.getServletPath();
120: }
121:
122: public HttpSession getSession(boolean flag) {
123: return request.getSession(flag);
124: }
125:
126: public HttpSession getSession() {
127: return request.getSession();
128: }
129:
130: public boolean isRequestedSessionIdValid() {
131: return request.isRequestedSessionIdValid();
132: }
133:
134: public boolean isRequestedSessionIdFromCookie() {
135: return request.isRequestedSessionIdFromCookie();
136: }
137:
138: public boolean isRequestedSessionIdFromURL() {
139: return request.isRequestedSessionIdFromURL();
140: }
141:
142: /** @deprecated use isRequestedSessionIdFromURL instead. */
143: public boolean isRequestedSessionIdFromUrl() {
144: return request.isRequestedSessionIdFromUrl();
145: }
146:
147: public Object getAttribute(String s) {
148: if (s != null
149: && (s.equals(INC_SERVLET_PATH) || s
150: .equals(INC_REQUEST_URI))) {
151: return jspFile;
152: }
153: return request.getAttribute(s);
154: }
155:
156: public Enumeration getAttributeNames() {
157: return request.getAttributeNames();
158: }
159:
160: public String getCharacterEncoding() {
161: return request.getCharacterEncoding();
162: }
163:
164: public int getContentLength() {
165: return request.getContentLength();
166: }
167:
168: public String getContentType() {
169: return request.getContentType();
170: }
171:
172: public ServletInputStream getInputStream() throws IOException {
173: return request.getInputStream();
174: }
175:
176: public String getParameter(String s) {
177: return request.getParameter(s);
178: }
179:
180: public Enumeration getParameterNames() {
181: return request.getParameterNames();
182: }
183:
184: public String[] getParameterValues(String s) {
185: return request.getParameterValues(s);
186: }
187:
188: public String getProtocol() {
189: return request.getProtocol();
190: }
191:
192: public String getScheme() {
193: return request.getScheme();
194: }
195:
196: public String getServerName() {
197: return request.getServerName();
198: }
199:
200: public int getServerPort() {
201: return request.getServerPort();
202: }
203:
204: public BufferedReader getReader() throws IOException {
205: return request.getReader();
206: }
207:
208: public String getRemoteAddr() {
209: return request.getRemoteAddr();
210: }
211:
212: public String getRemoteHost() {
213: return request.getRemoteHost();
214: }
215:
216: public void setAttribute(String s, Object obj) {
217: request.setAttribute(s, obj);
218: }
219:
220: public void removeAttribute(String s) {
221: request.removeAttribute(s);
222: }
223:
224: public Locale getLocale() {
225: return request.getLocale();
226: }
227:
228: public Enumeration getLocales() {
229: return request.getLocales();
230: }
231:
232: public boolean isSecure() {
233: return request.isSecure();
234: }
235:
236: public RequestDispatcher getRequestDispatcher(String s) {
237: return request.getRequestDispatcher(s);
238: }
239:
240: /** @deprecated use ServletContext.getRealPath(java.lang.String) instead. */
241: public String getRealPath(String s) {
242: return request.getRealPath(s);
243: }
244:
245: public java.lang.StringBuffer getRequestURL() {
246: return null;
247: }
248:
249: public java.util.Map getParameterMap() {
250: return null;
251: }
252:
253: public void setCharacterEncoding(java.lang.String s) {
254: }
255: }
|