Sunil Rai
Sunil Rai

Reputation: 432

How to capture Liferay Logged In User details in JSP (Say email-ID , name etc)

I want to capture Liferay Logged In User details in JSP (Say email-ID , name etc). I dont want to use any framework. I am new to JAVA and Liferay so any detailed step will be a great help for me to proceed. Thanks in advance.

Upvotes: 2

Views: 9036

Answers (3)

Michael Bravo
Michael Bravo

Reputation: 1

You can also get the user information in a JSP using the following:

long uid = com.liferay.portal.util.PortalUtil.getUserId(request);

User user = UserLocalServiceUtil.getUserById(uid);

Upvotes: 0

Anuj Balan
Anuj Balan

Reputation: 7729

In any of your login jsp pages, you can get the user object of the one who logged in by calling the method:

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
User objUser=themeDisplay.getUser();

From this objUser, you can get all the details you need.

Upvotes: 3

Martin Gamulin
Martin Gamulin

Reputation: 3865

If you add to your jsp

<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<liferay-theme:defineObjects />

than you can just use

<%= user.getEmailAddress() %>

or if you use jstl than

${user.emailAddress}

meaning <liferay-theme:defineObjects /> has put user object in page context.

Look up com.liferay.portal.model.User to see all properties available.

Upvotes: 4

Related Questions