Wednesday, March 18, 2015

[Liferay] Get HTTPServletRequest in portlet

Hello Friends,

In case you submitted need HttpServletRequest in your portlet, here is the code snippet.

HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
HttpServletRequest originalServletRequest= PortalUtil.getOriginalServletRequest(request);

This goes all the way from your custom code to  PortalImpl  and then PortletRequestImpl to get the request.

After getting request object it goes to find originalServletRequest.


This will be useful when you submitted your form or link without a proper portlet request or want to read a parameter from url.

Hope this helps.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.