简体   繁体   中英

Accessing http session in portlet

A jsp page saves values in the session using the following code

session.setAttribute("UserType", "customer");

These values need to be accessed in a jboss portlet. Using the following code to access the variable:

        String id = (String) renderRequest.getPortletSession().getAttribute("LoginId", PortletSession.APPLICATION_SCOPE);
    System.out.println("FROM SESSION: " + id);

I get null as the output. What do I need to do to access the session variable in the portlet?

From what I've seen, there's an extra bit of configuration needed in JBoss to enable portlet session and httpsession to intermingle: Chapter 8. Clustering Configuration

Check section: 8.3.1. Portal Session Replication

<web-app>
   <description>JBoss Portal</description>
   <!-- Comment/Uncomment to enable portal session replication -->
   <distributable/>
   ...
</web-app>

You can also see a discussion on the JBoss Community on the same topic: PortletSession vs HttpSession

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM