1 Reply Latest reply on Mar 24, 2008 7:43 AM by Shakti Purohit

    How to retrieve username?

    Shakti Purohit Newbie

      Hi all,

      I have deployed a portlet in JBoss. I login into the portal and fire a request. I also have a servlet which is part of the same web application of which portlet is a part. While trying to retrieve username using request.getPrincipal(), I get null.

      Any idea as to why I am getting null username? Please provide a way to retrieve username from http servlet request.

      Thanks,
      Shakti

        • 1. Re: How to retrieve username?
          Shakti Purohit Newbie

          Okay found it out.

          In my portlet I set a session variable as
          PortletSession session = request.getPortletSession(true);
          session.setAttribute("userName", user, PortletSession.APPLICATION_SCOPE)

          Since the varialbe is app scoped it is available in servlet as session.getAttribute("userName").

          Thanks,
          Shakti