Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Liferay portlet: Passing attributes to JSP
public class CustomPortlet extends MVCPortlet {
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
User currentUser = themeDisplay.getUser();
renderRequest.setAttribute("currentFirstName", currentUser.getFirstName());
// Add attributes as required
super.doView(renderRequest, renderResponse);
<%@ taglib uri="" prefix="portlet" %>
<portlet:defineObjects />
<div> Your first name is: <%= request.getAttribute("currentFirstName"); %> </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment