hi Mark,
Are there any listeners to listen to Login and logout events?
- I am aware of HttpSessionListener which listens to HttpSession events (sessionCreated, sessionDestroyed). I defined a custom class which implements SessionListener, and declared in web.xml of my portlet pacakge.
In sessionDestroyed() method, to perform some operations, I want to retrieve some details from current session. But the session values are always coming as null.
Before session expiration, in portal screens, I set attributes into session in all the following ways.
1) IContext context = com.webmethods.portal.bizPolicy.impl.ContextFactory.acquireContext(true);
context.setAttribute("iContextAttr", "IContext Attr", IContext.SCOPE_SESSION);
2) PortletSessionImpl portletSessionImpl = (PortletSessionImpl) this.getFacesContext().getExternalContext().getSession(false);
portletSessionImpl.setAttribute("sessionImplAttr", "Session Impl Attr");
3) HttpServletRequest currentRequest = PortalServlet.getCurrentRequest();
HttpSession session = currentRequest.getSession(true);
session.setAttribute("sessionAttr", "Session Attribute");
If I try to get these values in sessionDestroyed() method of my Custom Session Listener - I am getting following results:
1) [b]Result[/b]: null
2) [b]Result[/b]: null pointer exception - External context is null - hence cannot invoke getSession method.
3) [b]Result[/b]: null pointer exception - Current Request is null - hence can not invoke getSession method;
4) HttpSession sessionObj = sessionObj.getSession(); (sessionObj is the input parameter of type SessionEvent, in sessionDestroyed() method)
sessionObj.getAttribute("sessionAttr");
[b]Result[/b]: null
[color="green"]Is there any other way where I can set attributes to session, so that those values can be retrieved in sessionListener methods?[/color]
I tried in a sample dynamic web project, which includes only 1 jsp and 1 servlet. In that project, i am able to get session attributes(which I set in jsp page befor session gets destroyed) in sessionListener methods.
Kind regards,
Raja sekhar Kintali
#MWS-CAF-Task-Engine#webMethods-BPMS#webMethods