K
kebabkongen
Hi,
I am quite new to JSTL, and wonder how to pass parameters from one
included page to another.
In the first page I have access to an array through its tag library (as
I understand it)
Later, I include the output from another page with Ajax. I would like
to pass this array to the page that is imported by Ajax, but haven't
figured out how to do this.
Here is part of my code:
page1.jsp:
....
<c:set var="alternatives" scope="request" value="${myBean.myArray}"/>
<c:set var="counter" scope="page" value="0"/>
<c:forEach items="${myBean.myArray}" var="alternative" begin="0">
<c:set var="counter" scope="page" value="${counter + 1}"/>
<input type="radio" name="alt" id="alt${counter}"
value="alt${counter}"> <label
for="alt${counter}">${alternative}</label>
</c:forEach>
....
page2.jsp (imported via Ajax call, NB! this does not work!!):
....
<c:set var="counter" scope="page" value="0"/>
<c:forEach items="${requestScope.alternatives}" var="alternative"
begin="0">
<c:set var="counter" scope="page" value="${counter + 1}"/>
<input type="radio" name="alt" id="alt${counter}"
value="alt${counter}"> <label
for="alt${counter}">${alternative}</label>
</c:forEach>
....
I was hoping the ${requestScope.alternatives} would refer to the array
placed in the request scope in the beginning of page1, but it doesn't
seem to work that way.
Anyone can help me find out of this? How do I pass the myArray[]
element so that it can easily be picked up from page2.jsp?
Regards -P
I am quite new to JSTL, and wonder how to pass parameters from one
included page to another.
In the first page I have access to an array through its tag library (as
I understand it)
Later, I include the output from another page with Ajax. I would like
to pass this array to the page that is imported by Ajax, but haven't
figured out how to do this.
Here is part of my code:
page1.jsp:
....
<c:set var="alternatives" scope="request" value="${myBean.myArray}"/>
<c:set var="counter" scope="page" value="0"/>
<c:forEach items="${myBean.myArray}" var="alternative" begin="0">
<c:set var="counter" scope="page" value="${counter + 1}"/>
<input type="radio" name="alt" id="alt${counter}"
value="alt${counter}"> <label
for="alt${counter}">${alternative}</label>
</c:forEach>
....
page2.jsp (imported via Ajax call, NB! this does not work!!):
....
<c:set var="counter" scope="page" value="0"/>
<c:forEach items="${requestScope.alternatives}" var="alternative"
begin="0">
<c:set var="counter" scope="page" value="${counter + 1}"/>
<input type="radio" name="alt" id="alt${counter}"
value="alt${counter}"> <label
for="alt${counter}">${alternative}</label>
</c:forEach>
....
I was hoping the ${requestScope.alternatives} would refer to the array
placed in the request scope in the beginning of page1, but it doesn't
seem to work that way.
Anyone can help me find out of this? How do I pass the myArray[]
element so that it can easily be picked up from page2.jsp?
Regards -P