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>
<%}%>
You can’t include one scriptlet inside another: what’s the point?
Is this what you wanted? I’m asking because
loopTimeisn’t the ‘loop counter’ in your code, it’s loop upper boundary.