You will often have to built a URL leading to a specific portlet without knowing on which page it was placed. In order to find the page (layout) containing your portlet and building a valid LiferayPortletURL you can use the following code:
ThemeDisplay themeDisplay = (ThemeDisplay)liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout targetLayout = themeDisplay.getLayout(); ListallLayouts = LayoutLocalServiceUtil.getLayouts(-1, -1); layoutloop: for(Layout l:allLayouts){ LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet)l.getLayoutType(); List portletIdList = layoutTypePortlet.getPortletIds(); for(String portletId: portletIdList ){ if(portletId.equalsIgnoreCase(*your portletId*)){ targetLayout = l; break layoutloop; } } } LiferayPortletURL targetUrl = PortletURLFactoryUtil.create(liferayPortletRequest, *your portletId*, targetLayout .getPlid(), PortletRequest.RENDER_PHASE);