How to fetch and display the last login time for the logged in user in portal theme

7 comments



Sometimes it's an explicit requirement of the website to display the last login time for the logged in users. By default Websphere portal logs the user's' last login time in portal DB itself and we can easily fetch that with the help of PUMA API.

// For new PUMA user object
com.ibm.portal.um.User user = pumaProfile.getCurrentUser();
UserImpl userImpl = (UserImpl)user;
userImpl.getDescriptor().getLastLoginTime();
// For old PUMA user object
com.ibm.wps.puma.User oldUser = (com.ibm.wps.puma.User)request.getUser();
oldUser.getDescriptor().getLastLoginTime();

7 comments:

venky said...

Thanks for this post

vijay said...

Sorry to be very basic. Where to use this code?

Arun Khurana said...

You can use the same code directly in theme's default.jsp or in the doView() method of the portlet ?

vijay said...

Where can i find the file arun? I tried customizing themes and layouts but i can't recognize the correct directory. Can you pls share a post on the same.

vijay said...

I just copied the code in a script tag arun and when opened in the browser, the login page is not displayed. Instead JSP Error page is shown.

Arun Khurana said...

Did you import the necessary packages in your JSP file ?

Magendhiran said...

I'm using Portal 7 , i'm not sure what imports i need to add for method UserImpl , i tried old puma which is not working to me. pls help me here

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club