Home | Previous | Next


Use the <c:import> tag to dynamically include JSP pages

Commerce uses the <c:import> tag to dynamically include JSP pages.

The <c:import> tag, part of the Java Server Tag Library, supports relative and absolute URLs. The standard <jsp:include> tag only supports relative URLs.

To avoid problematic behavior, such as JSP fragments being displayed twice, surround <c:import> with <% out.flush(); .

  
<%out.flush();%>
  <c:import url="../../../Snippets/ReusableObjects/InventoryCountDisplay.jsp">

    <c:param name="fulfillmentCenterId" 
             value="${CommandContext.store.fulfillmentCenterId}" />

    <c:param name="itemSpcId" 
             value="${catalogEntry.itemspc_id}"/>

    <c:param name="storeId" 
             value="${WCParam.storeId}"/>

  </c:import>
<%out.flush();%>

Flushing the buffer before and after imports ensures that no child content is written to the parent's cache entry.

The out.flush statement is required for all <c:import> statements, not just those for fragments. Even if the page is being cached using full-page caching, the out.flush tags are still required to surround the <c:import> tags.

+

Search Tips   |   Advanced Search