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.
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").