-
1. Re: Accessing session attributes in a portlet
apemberton Jan 14, 2009 12:23 AM (in response to segal96)Steve:
You might clarify by adding your Portal version info, etc., but I'll take a stab at an answer anyway.
Your servlet listener will intercept requests to the underlying portal servlet, whereas the portlet code you showed there is accessing the portlet's session. These two session are inherently different (different WAR deployments)
Instead try the following in your portlet code:Navigation.getPortalRuntimeContext().getSession().getAttribute("attr1");
This will allow you to access the underlying portal servlet's global session from your portlet code. -
2. Re: Accessing session attributes in a portlet
segal96 Jan 14, 2009 4:04 PM (in response to segal96)I am using Jboss portal 2.6.8. I tried the code below, but I still get null value when attempting to read "attr1".
I set "attr1", an HttpSession attribute, in the doFilter() of my filter class. I believe that this is set before the request gets to the portal servlet.
I'm not to JB portal, but from what I am reading, there might not be a way to read this attribute from my portlet.
Here is a similar post with no response from '05:
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122211#4122211
Thoughts? -
3. Re: Accessing session attributes in a portlet
apemberton Mar 9, 2009 2:44 PM (in response to segal96)Ah, understood. See the logic in PortletTag.java from the JBoss Portal code base to see how to access the underlying HttpServletRequest.
Something like the following will get you access to the underlying ServletRequest:ServletRequest req = pageContext.getRequest(); PortletInvocation invocation = (PortletInvocation)req.getAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION); HttpServletRequest request = invocation.getDispatchedRequest();