Reputation: 356
I am writing a method in JSP which dump rows of a table:
<%!
void dumpRows(List<MyClass> obList){
int a = 10;
for(int i = 0; i<100; i++){
%>
//lots of HTML code which uses the variables from the dumpRows method
<td> <%=a*i%> </td>
<%
}//for loop ends
}//method ends
%>
but it is erroring out. There's something wrong with the JSP grammar. Please help me on how can I achieve that
Upvotes: 0
Views: 229
Reputation: 11579
I think the problem is that you are mixing <%!
, <%
and <%=
.
If you separate business logic and view it will be much easier and clear.
You can use JSTL tag <c:forEach>
to output your html table.
Upvotes: 1
Reputation: 13844
<%!
void dumpRows(List<MyClass> obList){
int a = 10;
for(int i = 0; i<100; i++){
%>
//lots of HTML code which uses the variables from the dumpRows method
<td> <%=a*i%> </td> //here problem
<%
}//for loop ends
}//method ends
%>
write this way to print <%=a*i%>
Upvotes: 2