Are global variables in the included file (using <jsp:include/>) available in the file that includes it?
Created May 7, 2012
Using <%@ include file="include.jsp" %> will make outside variables to be seen in the included page, as this will result in a compilation-time static include generating 1 single Servlet to accomplish JSP requests.
If you want to pass some variables from an outside page to an included one with a dynamic include you have to pass some parameters as shown following:
Dynamic include will be obviously slower than statics, as they will be accomplished with one more request to the server made by the including page to display included content inside it.
<%
...
String myvar = "hello";
%>
<jsp:include page="included.jsp" flush="true" >
<jsp:param name="myvar" value="<%= myvar %>" />
</jsp:include>