Please read
this article to understand how to properly structure a web application. That means no database access in the controllers or views, and no
Java code int he JSP.
The database access should be performed by model classes, which are called by the page controller. The obtained data is placed in request scope by the controller, which then forwards to the JSP, which uses JSTL and EL to construct the required HTML.