How to get parameters from URL in Liferay portlet?

Mayur Patel picture Mayur Patel · Feb 5, 2011 · Viewed 43.1k times · Source

I'm using jsp of out-of-box portlet like feed.jspf in Liferay 6:

String articleId =null;
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
articleId = httpReq.getParameter("articleId");

It is giving a null value whether in custom portlet or in .jsp files, but it should have a value.

Answer

FoX picture FoX · Feb 8, 2011

Sure, you can always use the standard HttpServletRequest to retrieve your parameters from. You can get this request by using the PortalUtil class, like in the following example:

HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest);
String articleId = request.getParameter("articleId");