This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Terry Chambers wrote:Do I need to create an object to hold the data from each row and then just create multiple objects? If yes, I am still unsure how I would get the items to display in the HTML of the page.
Yes, that's what you need to do. Create an object to hold the data from each row, and build a List of those objects as you read them from the ResultSet. (An ArrayList would be fine for that.)
And don't do any of that in a JSP. Do it all in a servlet. When you have the List filled up, add it as a variable to the request context. Then forward to a JSP. All the JSP should do is to have some JSTL code which gets that variable from the request context and iterates through it. That way it gets each of the objects you extracted from the ResultSet. If you designed the object so that its class has suitable getter methods, you can use JSTL to get the fields from the object and output them, wrapped in suitable HTML.
Paul is spot on. Resultsets should never go anywhere near a JSP!
To expand a bit on Paul's post, you'd iterate over the List of objects that capture the data (could be a bean, could be as simple as a string array) using the JSTL's <c:forEach> tag. If your are creating a <table> element to display the info, each iteration would create a new <tr> for the table.