Search code examples
javaportletliferayjsr168

How to get parameters from URL in Liferay portlet?


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.


Solution

  • 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");