create render URL By Liferay tag (liferay-portlet:renderURL) in JSP

liferay-portlet:renderURL is a custom tag provided by Liferay. This tag is used to create render URL.

In this article, I will be showing how to create render URL by liferay tag (liferay-portlet:renderURL)This tag works similarly as render URL by PortletURLFactoryUtil class. 

First of all, you need to create LiferayMVC portlet. You can refer separate blog on Creating MVC Portlet in Liferay to create project structure as per below screenshot.

render URL By Liferay tag (liferay-portlet:renderURL) in JSP - project stucture

I gave plugin project name as renderURL-by-LiferayTag and -portlet will be appended during project creation by Liferay IDE. I gave portlet class as com.opensource.techblog.portlet.RenderURLByLiferayTagPortlet.

Add following code in RenderURLByLiferayTagPortlet class.

//define log for this class
private static final Log _log = LogFactoryUtil.getLog(RenderURLByLiferayTagPortlet.class.getName());
 public void render(RenderRequest request, RenderResponse response)
 throws PortletException, IOException {" This is render method of RenderURLByLiferayTagPortlet");
   String data = request.getParameter("param");
   String data1= ParamUtil.getString(request, "param","");
   System.out.println("parameter with request.getParameter is =>"+data);
   System.out.println("parameter with ParamUtil.getString is =>"+data1);
  super.render(request, response);


  • We are simply reading request parameter and displaying it in logger. 

Add Liferay Tag (liferay-portlet:renderURL)

We will pass this parameter while creating render URL with Liferay Tag. We will add liferay tag in view.jsp. Next step is to add following code in view.jsp

<%@ taglib uri="" prefix="liferay-portlet" %>
<liferay-portlet:renderURL var="openPortletURL" copyCurrentRenderParameters="true" portletMode="<%=LiferayPortletMode.VIEW.toString() %>" 
  <liferay-portlet:param name="param" value="This is from Liferay TAG"/>
<a href="${openPortletURL}">Render Url created by Liferay TAG in JSP</a>
  • <liferay-portlet:renderURL> tag is used to create render URL. 
  • To avail this tag, we have added <%@ taglib uri=”” prefix=”liferay-portlet” %> taglib definition in this jsp.
  • the attribute of this tag is similar with <portlet:renderURL>. You can refer my blog on creating render URL with Portlet tag (<portlet:renderURL>). The only difference between these two tags are
    • Render URL created with <portlet:renderURL> can point to current portlet only.
    • Render URL created with <liferay-portlet:renderURL> can point to other portlet too. For this, we need to give plid and portletName attributes for the target portlet. 
    • If we are not providing these attributes to <liferay-portlet:renderURL> tag then it will create render URL which points to current portlet only.
  • You can set window state and portlet mode similarly that we set for <portlet:renderURL>
  • You can also pass additional parameter with <liferay-portlet:param> tag similarly <portlet:param> tag.
  • var attribute is used to hold this render URL so that we can refer it anywhere in JSP.
  • At the end, we created a new link and set its href with variable (var attribute defined in <liferay-portlet:param> tag) which holds render URL.

Save the view.jsp and deploy the portlet. Refresh the page and you will see this link. Click on this link and you will see the paramter’s (param) value (“This is from Liferay TAG”) is printed in server console.

Summing Up

  • <liferay-portlet:renderURL> liferay tag used to create render URL
  • We can set portlet mode and window state while creating renderURL
  • We can pass additional parameter by <liferay-portlet:param> child tag just like <portlet:param> under <portlet:renderURL>.
  • renderURL created by <liferay-portlet:renderURL> tag can points to same as well as other portlets.
  • You may visit this link to understand render and action phase of portlet.

Following are other possible ways to create render URL in Liferay

Download Source

Download Source

Recommended For You

About the Author: Nilang

Nilang Patel is a technology evangelist who loves to spread knowledge and helping people in all possible ways. He is an author of two technical books - Java 9 Dependency and Spring 5.0 Projects.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.