?
Solved

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

Posted on 2006-05-23
5
Medium Priority
?
221 Views
Last Modified: 2011-09-20
<%      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 ..,
0
Comment
Question by:mali_ini
  • 2
3 Comments
 
LVL 14

Expert Comment

by:boonleng
ID: 16751465
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>
0
 
LVL 14

Accepted Solution

by:
boonleng earned 1000 total points
ID: 16751569
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>
</c:forEach>
0
 
LVL 28

Assisted Solution

by:rrz
rrz earned 1000 total points
ID: 16752128
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
 http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21860831.html    

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question