Question: I have a simple statement in a servlet file that will go through the database and get the result set

```
ResultSet AssignmentList = stmt.executeQuery("SELECT * FROM Assignments WHERE " + projectID + "= Pid;");
request.setAttribute("assignmentList", AssignmentList);

```

As you can see I'm sending the `ResultSet` to a JSP file. And in that JSP file I tried to iterate through it like this.

```
<table class="CSSTableGenerator">
    <thead>
    <tr>
        <th>Aid</th>
        <th>Title</th>
        <th>Task</th>
        <th>ID of User Responsible</th>
    </tr>
    </thead>
    <tbody>

    <c:forEach items="${assignmentList}" var="item">
        <tr>
            <td>${item.Aid}</td>
            <td>${item.Title}</td>
            <td>${item.Task}</td>
            <td> ${item.UserID}</td>            
        </tr>
    </c:forEach>

    </tbody>
</table>

```

but when I do that I get an error. 
Am I suppose to iterating in wrong way, or is it not possible to iterate through a `ResultSet`.

Answer: 
There a class somewhere in JSP called Results that does exactly what you need. You construct it from a ResultSet, you can close the ResultSet and the connection, and the Results has an Iterable array of rows that are themselves maps.
You can try with [SQL Tag Library](http://docs.oracle.com/javaee/5/tutorial/doc/bnald.html) that is designed for accessing databases in a JSP page.

I have already shared an approach for [Getting values from mysql database to show in JSP (JAVA)](https://stackoverflow.com/questions/24120224/getting-values-from-mysql-database-to-show-in-jsp-java/24121273#24121273)) along with sample code that might help you.

**Logic:** Simply fetch the data form the database in Servlet and populate the data in a POJO class and set the final list of all the records as request attribute and finally forward the request to the JSP page.