Lost Session Attributes

Hello guys:

I’ve a portlet which is called with parameters, this porlet set some attributes for the session:

javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest)com.webMethods.portal.framework.impl.PortalServlet.getCurrentRequest();

HttpSession reqsession = request.getSession(true);
reqsession.setAttribute(“someAttribute”, attribValue);

Later in this same porlet I make a redirect to another porlet where I get this attribute normally:

myValue = (String) reqsession.getAttribute(“someAttribute”);

But when I choose another portlet from the left navigation panel the attribute seems to be lost because when I use getAttribute it return null.

Best regards

I know you are trying to ensure that you’re accessing a shared session object, but i wonder if you might be accessing a session object that is isolated for each Portlet Application?

One way to check would be to attach to your app with a debugger and see if the Session instance is the same in each portlet application.

mimel:

Seems to be that situation, the session is isolated from the other portlet application, but it should not, Am I right?, I need to work with a shared session, I wonder if the approach I’m using it’s correct…

regards

HttpSession reqsession = PortalServlet.getCurrentRequest().getSession(true);

reqsession.getId();

Return the same Id from both portlets.

I resolved using:

context = ContextFactory.acquireContext(false);

context.setAttribute(“userID”, vuserID, IContext.SCOPE_SESSION);
context.getAttribute(“userID”, IContext.SCOPE_SESSION);

regards.

If MWS is in clustered mode, how this session value works?

By now we’re not working in clustered mode.

Regards.

Sessions (and their attributes) are not replicated across a cluster.
Regards,
–mark