0
votes

I have form on a porlet, after submission of that form, page is redirecting to another portlet for that i am using actionResponse.sendRedirect("/abc/bcd/newWebPage") and i am landing on to different page. One that page the same potlet is added with different screen, Now i want to display a success message on next page.

for that i am using portlet session and passing parameter to jsp.

PortletSession session = actionRequest.getPortletSession();
                            session.setAttribute("SUCCESSA", "Successfully",PortletSession.APPLICATION_SCOPE);

But its not working.

Any help how to achieve that?

1

1 Answers

0
votes

When you say One that page the same potlet is added with different screen, I understand that you have another instance of the same portlet in different page. By the way, you haven't explained what is not working for you. I assume you are wondering how to read in the JSP page. It's pretty straight forward:

In Controller:

PortletUtils.setSessionAttribute(request, "SUCCESSA", "Successfully", PortletSession.APPLICATION_SCOPE);

In JSP:

pageContext.setAttribute("succcessa", PortletUtils.getSessionAttribute(renderRequest, "SUCCESSA", PortletSession.APPLICATION_SCOPE));

The PortletUtils does the same as setting the attribute using the PortletRequest object but its preferrable.

To remove the session attribute:

PortletUtils.setSessionAttribute(request, "SUCCESSA", null, PortletSession.APPLICATION_SCOPE);

The implementation of PortletUtils is that it removes the session attribute if value is null, if a session existed at all.