0
votes

I'm developing a liferay portlet. In this portlet I fetch the user information from database in portlet class and save them in a resultset. How can I share this resultset between portlet class and jsp pages?

2

2 Answers

0
votes

Save the user objects in an arraylist and use session to save this arraylist. You can make it available throughout the portlet. Setting and getting is explained in this.

Example

0
votes

It's recommended to hold the session thin, in this case I would put the data in the request.

java:

public class MyTestPortlet extends MVCPortlet {
    @Override
    public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
        User user = getCurrentUser(renderRequest);
        renderRequest.setAttribute("UserName", user.getScreenName());
        super.doView(renderRequest, renderResponse);
    }
...
}

jsp:

Hello ${UserName}!!!