}
else if (create)
{
// For sure we need a session we will obtain a valid one
HttpSession hsession = realReq.getSession();
PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getPortletApplication();
psession = new PortletSessionImpl(hsession, windowContext.getId(), portletApp.getPortletContext());
}
else
{
// Here we can try an existing session but it may return null
HttpSession hsession = realReq.getSession(false);
//
if (hsession != null)
{
PortletApplicationImpl portletApp = (PortletApplicationImpl)container.getPortletApplication();
psession = new PortletSessionImpl(hsession, windowContext.getId(), portletApp.getPortletContext());
}
}
//
return psession;