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.
Split a jsp method in multiple scriplets to include html code in between
Question
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
Solution 2
OTHER TIPS
<%!
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%>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow