8 Replies Latest reply on Mar 8, 2006 7:33 PM by bulloncito

    PortletSession vs HttpSession

    bcollins

      I'm running portal 2.0 in jboss 4.0.2. The issue I'm having is trying to get HttpSession attributes in PortletSession.

      PortletSessionImpl uses a prefix of "javax.portlet.p." which prevents HttpSession attributes from being returned. The private HttpSession in PortletSessionImpl has the attributes I need but the getters will not return them due to the prefix.

      PortletSessionIpml implements PortletSession which states:
      "Therefore all HttpSession listeners do apply to the portlet session and attributes set in the portlet session are visible in the HttpSession and vice versa."....so (per spec) shouldn't these be available?

      Is there a work around to get to the HttpSession attributes?

        • 1. Re: PortletSession vs HttpSession
          sandeeppujar

          I am also having the same problem, any pointers ? solutions..?

          Thanks,
          Sandeep

          • 2. Re: PortletSession vs HttpSession

            you don't need a work around, you need to read the java doc ;)

             req.getPortletSession().getAttribute("", PortletSession.APPLICATION_SCOPE);
            



            • 3. Re: PortletSession vs HttpSession
              bcollins

              You are correct...I guess I should have read the code as well...

               if (i == PORTLET_SCOPE)
              
               {
              
               s = prefix + s;
              
               }
              
               return session.getAttribute(s);


              Thanks.

              • 4. Re: PortletSession vs HttpSession
                jason.bradfield

                I am having trouble with the below....

                I have a servlet filter mapping to the PortalServlet.
                it is doing the following:

                HttpServletRequest req = (HttpServletRequest) request;
                HttpSession session = req.getSession();
                session.setAttribute("REQUEST-URI", req.getRequestURI());


                In my portlet I am doing this..
                String requestUri = (String) request.getPortletSession()
                 .getAttribute("REQUEST-URI", PortletSession.APPLICATION_SCOPE);

                I am getting null returned

                Can anyone give me any pointers as to why this is not working..
                I am using Portal 2.0 and AS 4.0.3.

                • 5. Re: PortletSession vs HttpSession

                  Are your filter and your portlet deployed in the same WAR context ?
                  Rembember: each context has its own distinct session!

                  There is a config option to share the portal's session across all contexts though. Check the docs for how to activate that.

                  • 6. Re: PortletSession vs HttpSession
                    j1

                    Hi,
                    in method void doView(JBossRenderRequest request, JBossRenderResponse response) i need to get a information about user like user IP,...
                    In JSP I do it using request.getRemoteAddr() where request was HttpServletRequest.

                    How Can I do it in portlet?

                    • 7. Re: PortletSession vs HttpSession
                      bulloncito

                      --- Are your filter and your portlet deployed in the same WAR context ?
                      --- Rembember: each context has its own distinct session!

                      --- There is a config option to share the portal's session across all contexts though. Check the docs for how to activate that.

                      What do you mean by that ? We've deployed several portlets from diferent WARs, and each keeps it's own HTTP session wich is in turn wrapped by PortalSession thru that prefix thing, will this configuration merge session from different portlets from different applications ? or just this prefix-domain thing ?

                      • 8. Re: PortletSession vs HttpSession
                        bulloncito

                        ... just to complement, we've already tried this

                        http://wiki.jboss.org/wiki/Wiki.jsp?page=DistributedPortletSession

                        with no success. There is a reference to a " Portal Session " ... does this mean regular " HttpSession " ? or is there another session besides PortletSession and HttpSession