1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17packageorg.apache.jetspeed.request;
1819import javax.servlet.http.HttpServletRequest;
20import javax.servlet.http.HttpServletRequestWrapper;
21import javax.servlet.http.HttpSession;
2223/***24 * PortalRequest wraps the original request to the portal and keeps local25 * references to properties like contextPath, servletPath and the Session26 * when its created.27 * <p>28 * Some web servers like WebSphere don't store these properties inside the29 * request but derive them dynamically based on the web application context30 * in which they are invoked.31 * </p>32 * <p>33 * For cross-context invoked portlet applications, getting access to the34 * portal contextPath using requestContext.getRequest().getContextPath()35 * this clearly is a problem. Also, access to the Portal Session is not36 * possible this way.37 * </p>38 * <p>39 * The requestContext.request is actually wrapped by this class which solves40 * the problem by storing a reference to the actual properties at the time41 * of creation and returning 42 * </p>43 * 44 * @author <a href="mailto:ate@douma.nu">Ate Douma</a>45 * @version $Id$46 */47publicclassPortalRequestextends HttpServletRequestWrapper
48 {
49privatefinal String contextPath;
50privatefinal String servletPath;
51privatefinal HttpSession session;
5253publicPortalRequest(HttpServletRequest request)
54 {
55super(request);
56 contextPath = request.getContextPath();
57 servletPath = request.getServletPath();
58 session = request.getSession(true);
59 }
6061public String getContextPath()
62 {
63returnthis.contextPath;
64 }
6566public String getServletPath()
67 {
68returnthis.servletPath;
69 }
7071public HttpSession getSession()
72 {
73returnthis.session;
74 }
7576public HttpSession getSession(boolean create)
77 {
78returnthis.session;
79 }
80 }