1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.request;
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletRequestWrapper;
21 import javax.servlet.http.HttpSession;
22
23 /***
24 * PortalRequest wraps the original request to the portal and keeps local
25 * references to properties like contextPath, servletPath and the Session
26 * when its created.
27 * <p>
28 * Some web servers like WebSphere don't store these properties inside the
29 * request but derive them dynamically based on the web application context
30 * in which they are invoked.
31 * </p>
32 * <p>
33 * For cross-context invoked portlet applications, getting access to the
34 * portal contextPath using requestContext.getRequest().getContextPath()
35 * this clearly is a problem. Also, access to the Portal Session is not
36 * possible this way.
37 * </p>
38 * <p>
39 * The requestContext.request is actually wrapped by this class which solves
40 * the problem by storing a reference to the actual properties at the time
41 * of creation and returning
42 * </p>
43 *
44 * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
45 * @version $Id$
46 */
47 public class PortalRequest extends HttpServletRequestWrapper
48 {
49 private final String contextPath;
50 private final String servletPath;
51 private final HttpSession session;
52
53 public PortalRequest(HttpServletRequest request)
54 {
55 super(request);
56 contextPath = request.getContextPath();
57 servletPath = request.getServletPath();
58 session = request.getSession(true);
59 }
60
61 public String getContextPath()
62 {
63 return this.contextPath;
64 }
65
66 public String getServletPath()
67 {
68 return this.servletPath;
69 }
70
71 public HttpSession getSession()
72 {
73 return this.session;
74 }
75
76 public HttpSession getSession(boolean create)
77 {
78 return this.session;
79 }
80 }