I am trying to pass two values from JSP1 to JSP2. I am using the below given codes in JSP1 and JSP2. I want to display the values of key and value in JSP2 but the output given in "Output" section below is getting displayed. I want these values to be passed to JSP2 to perform some logic on them. I want to move back to JSP1 after the logic in JSP2 get executed.
So JSP1 gets values from Controller class in Java. There is a loop in JSP1 and JSP2 is called inside the loop in JSP1. Now I am not able to access the values that are being passed from loop but I am able to access the values sent from Controller class to JSP1 in both JSP1 and JSP2. So the issue is being caused as the values from loop are not being passed to JSP2.
JSP1
<% request.setAttribute("key", "${entityitem.key}"); %>
<% request.setAttribute("value", "${entityitem.value}"); %>
<jsp:include page="JSP2.jsp"/>
JSP2
<%= request.getAttribute("key") %> : <br>
<%= request.getAttribute("value") %>
Output:
${entityitem.key}
${entityitem.value}
Desired output: Values in
${entityitem.key}
${entityitem.value}