The key lies in the varStatus attribute of <c:forEach>, the specific code is as follows: <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <th>serial number</th> <th>Name</th> </tr> <c:forEach var="student" items="${ students}" varStatus="status"> <tr> <td>${ status.index + 1}</td> <td>${ student.name}</td> </tr> </c:forEach> </table> Note: status.index starts from 0.