The JSP should know nothing about a database so that should be handled by a bean.
The key issue with JSPs is that it is for separation of logic from presentation. A poor programming style can lead to a mess however since it is easy enough to imbed a few hundred lines of Java code inside a JSP.
We also use an MVC architecture. The request comes into a servlet which packages the request and passes it to a bean for business logic processing and database lookups. The solution is then passed back to the servlet. The servlet then invokes the appropriate JSP depending upon the result supplied to it by the business login bean.
A JSP should know nothing about business logic or databases. It should only know how to take data and put it on the screen. The servlet should know nothing about business logic or databases or presentation. It should only know how to strip data from the screen and pass it to a bean for processing. The bean should know nothing about presentation but should know everything about business logic. If it needs data from a database, it should invoke a different bean that knows how to read data from the database. If this sounds a little like an
EJB environment, then you have been paying attention. Even without an EJB server, the EJB layout is still the best way to separate functionality into reusable classes.