2

I want to put a variable in the requestScope so I can use it in an other page. Unfortunately, the requestScope is totally empty in this other page. In fact, when I print #{requestScope} in both pages, they don't have the same memory adresse !

mainPage.jsp

<c:set var="foo" value="${myForm.myJavaObject}" scope="request" />

<c:forEach var="scope" items="${requestScope}">
    ${scope.key} // PRINTS EVERY VARIABLE IN THE REQUEST SCOPE, INCLUDING foo
</c:forEach>

<jsp:include page="./includedPage.jsp"/>

includedPage.jsp

<c:forEach var="scope" items="${requestScope}">
    ${scope.key} // PRINTS NOTHING
</c:forEach>

Same thing if try different scopes (session, application etc.). I don't get it. This method is all over the internet, so why is it not working? First time I use it.

0

1 Answer 1

1

It works if I include <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>. I don't get why though, as it is already included in the mainPage.jsp and because <jsp:include> is dynamic.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.