0

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.

Patrick
  • 6,495
  • 6
  • 51
  • 78

1 Answers1

0

try changing scope

<c:set var="myVariable" value="hello" scope="session"/>
Pankaj Sharma
  • 1,833
  • 1
  • 17
  • 22