I am working on a project and I need to be able to access a variable from an included jsp page. Each of my jsp pages include the header, footer and a variable like so;
<jsp:include page="header.jsp"></jsp:include>
<c:set var="myVariable" value="hello" />
<!-- content -->
<jsp:include page="footer.jsp"></jsp:include>
I have written a javascript function which uses this variable, for now lets just say:
console.log( '<c:out value="${myVariable}"/>' );
Now when this line is beneath the footer include page it works perfectly. However, I do not want to have my javascript code at the bottom of every page - it quickly becomes unmanageable and messy. Is there a way I can access this variable in the same way, but from within the footer.jsp page.