how to pass an initialising variable used in a for loop into a scriptlet to get the values iterated ?

<%      for (int _i0 = 0; ; ) { %>
               <c:set var ="_i0" value ="${_i0 + 1}" ></c:set>
                      <c:set var="_p0_7" value="<%=PolicyQuery.getINSURED_ZIP(_i0)%>"></c:set>//here s te pbm.
<%} %>
hi i am getting error saying that _i0 could not be resolved.

i tried with the below added code too :
<%      for (int _i0 = 0; ; ) { %>
          <c:set var="_i0" value="<%=_i0%>" />
              <c:set var ="_i0" value ="${_i0 + 1}" ></c:set>
                      <c:set var="_p0_7" value="<%=PolicyQuery.getINSURED_ZIP(_i0)%>"></c:set>
<%} %>

can i get an immediate reply , its very urgent to resolve this ..,
Who is Participating?
boonlengConnect With a Mentor Commented:
You can use jstl forEach tag for looping
<c:forEach begin="1" end="10" var="_i0">
    <c:set var="_p0_7"><%=PolicyQuery.getINSURED_ZIP((Integer) pageContext.getAttribute("_i0") )%></c:set>
You cant put a scriptlet inside the jstl tag property, it should be in the content of the tag.
<c:set var="_i0"><%=_i0%></c:set>
rrzConnect With a Mentor Commented:
Try it this way.
<%      for (int _i0 = 0; ; ) { %>
             <c:set var ="_i0" value ="<%=_i0 + 1%>" ></c:set>
                  Long _i0 = (Long)pageContext.getAttribute("_i0");
                     <c:set var="_p0_7" value="<%=PolicyQuery.getINSURED_ZIP(_i0.intValue())%>"></c:set>
<%} %>

or maybe better  try  

<%      for (int _i0 = 0; ; ) { %>
                     <c:set var="_p0_7" value="<%=PolicyQuery.getINSURED_ZIP(_i0 + 1)%>"></c:set>
<%} %>

But  maybe better to go with forEach as boonleng suggested above  and as my last post at    

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.