JSP (w JSTL) passing arrays from one included page to another

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top