You need to separate the presentation from business logic.. Here is a simple how
You need a servlet (say DisplayController.java)
You need a JSP (MyView.jsp)
Then..through your web browser.. you should call the servlet (assuming you have configured the servlet in web.xml)
In the servlet, you will retrieve the contents from database and put the contents in a list or map or any data structure of your choice. Then you need to get that variable ready to be accessible by UI. That means you should send the variable by adding it at as an attribute to the request.
Then pass on the view to JSP. You can do that by using the RequestDispatcher
In JSP you should use your scriptlets/JSTL to just iterate over the results variable that is retreived from attributes which is a list or or map and display them
Hope its clear.. Can ask if its not!
A teeny tiny vulgar attempt to get you to buy our stuff
Two software engineers solve most of the world's problems in one K&R sized book