Home
JSP dynamic includes
When using the <jsp:include> tag to dynamically include a JSP fragment into another JSP, always set the flush attribute to true so that those fragments will be cached correctly by DynaCache. In Example | -1, we include the JSP fragment to display in-stock inventory while ensuring that the flush attribute is correctly set.
Example 5-1 JSP dynamic include with flush
<jsp:include path="../../../Snippets/ReusableObjects/InventoryCountDisplay.jsp" flush="true"><jsp:param name="fulfillCentreId" value="${CommandContext.store.fulfillmentCenterId}" /><jsp:param name="itemSpcId" value="${catalogEntry.itemspc_id}" /><jsp:param name="storeId" value="${WCParam.storeId}" /></jsp:include>
![]()
The JSPWriter buffers the data rather than flushing it to the cache's writer when interpreting the include tag. The buffering prevents DynaCache from knowing when the application stopped writing the data to the parent writer. As a result, the child fragment's content might also be cached as part of the parent's cache entry, causing the child fragment to appear twice.