(I wrote this huge reply then my computer blue screened.
)
Basically to save trouble you need to provide separate levels of logic: JSPs for presentation, Java Beans for business, and another for persistence.
Your JSP should only perform display related duties. It should make a call to the Java Bean, which should make the data the JSP requires available (without the JSP having any knowledeg of how the data was created or where it came from)
The bean can then get a connection, perform a query, parse the results then make them available to the JSP.
There isn't really any separation here between the business and persistence layers, so preferably the bean would make a call to another component to liase between the bean and the persitent storage. We do have the advantage of maintaining the database resources in a single place thought.
So, to get back to the original question:
the JSP should call your bean without any knowledge of what the bean will do. All the JSP knows is that the bean will have the data it requires.
The bean then makes a call to the persistence layer, either by itself (not recommended but easier) or through an intermediary.
I guess what I'm trying to say is: no Database Resiources (Connections, ResultSets etc) in a JSP, and all resource manageent should happen in one place so you don't create resource leakage.
DOM
(hope this said what I originally wanted to say, it never comes out right the second time...
)