With the below code I need to maintain the inclusion load order but I’m wondering if there’s a better way to accomplish this syntactically without using so many <% %>
base.jsp
<%
List<String> cssFiles = new ArrayList<String>();
List<String> jsFiles = new ArrayList<String>();
/*
* Load all CSS/JS files we want on every page
*/
%>
<%@ include file="includes/jquery.jsp" %>
<%
cssFiles.add("/css/global");
jsFiles.add("/js/global");
%>
<%@ include file="includes/jquery_ui.jsp" %>
view.jsp
<%@ include file="../base.jsp" %>
<% cssFiles.add("/css/content/view"); %>
<%@ include file="../header.jsp" %>
A significantly better way would be to use Model-View-Controller pattern and move all code into Controller, so your JSPs won’t have that many
<% %>in a first place.