Included JSP pages aren't recompiled

Issue

You are using jsp include directive <%include file= "path"%> in one of your JSP pages. After the main JSP page is compiled, changes to the included JSP don't take effect.   For example:   You have component that includes two other JSP pages: page 1 ("titles") and page 2 ("children"). The component is defined to start with

start.jsp:

...
<%
String[] selector = cqReq.getSelectors();
if (selector.length>0) {
if (selector[0].equals("child")) {
%>
<%@ include file="children.jsp" %>
<%
}
} else {%>
<%@ include file="titles.jsp" %>
<%
}
...
%>

If you change start.jsp, then children.jsp and titles.jsp are recompiled as well. If you only update the included JSPs, they are not recompiled.

Solution

Use a dynamic include mechanism. One possible solution is to use <cq:include file="path" > tag. For example:

<%@page import="com.day.cq.delivery.DeliveryHttpServletRequest"%>

<%@ taglib uri="/cqtlb" prefix="cq" %>

<cq:setpath name="/apps/designground/templates/test" />

<%

DeliveryHttpServletRequest cqReq = (DeliveryHttpServletRequest)request; String[] selector = cqReq.getSelectors();

if (selector.length>0) {

if (selector[0].equals("child")) {

%>

<cq:insertfile name="children.jsp" />

<% }

} else { %>

<cq:insertfile name="titles.jsp" /> <%}%>

Additional information

<%include file= "path"%> includes a static file, parsing the file’s JSP elements. Use this type of include only if the included page is static.

 Adobe

Get help faster and easier

New user?