• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retreiving atrributes from HttpSession in Portlet  RSS feed

RoshaniG Gopal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to retrieve an attribute stored in the HttpSession in a portlet. But I always get a value as "null". I am using Jboss portal 2.6.1 with JDK 5. Please help. Here is the code snippet.

HttpServletRequest httpServletRequest=(HttpServletRequest)pageContext.getRequest();
HttpSession httpSession=httpServletRequest.getSession();
String testString="jjksdhfadhs";
//httpSession.getServletContext().setAttribute("test", testString);
httpSession.setAttribute("test", testString);

portlet in doView)

PortletSession portletSession=request.getPortletSession();
Object attributeFromPortletRequest=portletSession.getAttribute("test");
On checking the portletSession.isNew(), I find it is a new object so what i have stored in the httpSession is not avialable here.

The Jboss reference guide =It is possible to have access to a portion of the portal session to store objects. The org.jboss.portal.api.session.PortalSession interface defines its API and is similar to the javax.servlet.http.HttpSession except that it does not offer methods to invalidate the session as the session is managed by the portal.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!