Reputation: 20895
I want to ask a question about the JSP. I writing the following code in the JSP page. However, when I set the <%= obj.getCounter()%>
(use-defined method) to be the loop counter, I found that it does not work. Can anyone help me? Thank you.
The following is the code.
<%
private int loopTime = <%= obj.getCounter()%>;
%>
<% for(int i=0; i<loopTime; i++) { %>
<tr>
<td><%= obj.getName() %></td>
<td><%= obj.getAge() %></td>
</tr>
<%}%>
Upvotes: 1
Views: 82
Reputation: 68006
You can't include one scriptlet inside another: what's the point?
<% int loopTime = obj.getCounter(); %>
Is this what you wanted? I'm asking because loopTime
isn't the 'loop counter' in your code, it's loop upper boundary.
Upvotes: 4