Reputation: 1635
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?
Upvotes: 0
Views: 1263
Reputation: 18827
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}!!!
Upvotes: 0
Reputation: 7729
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.
Upvotes: 0