How to set the <%= ...> in to a loop counter?

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>
<%}%>

Answers


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.


Need Your Help

Jquery/ PHP Show database after got updated

php jquery

I have this jQuery which updates the DB on blur. It works fine except I want the code to show the current DB value after it got updated. There is a value in the database the amount in the field wil...

capture one frame from a video file after every 10 seconds

python video video-capture

I want to capture from a video file one frame after every 10 seconds, So if anyone can help me for that i will be very thankful. my python code is like that: