If it were my app, I wouldn't use the JSP to query the database. Keep JSPs at the presentation layer. I might use a JSP to create an instance of an
EJB that would query the database. If it's just a query, then I would use a Session bean (or perhaps even a servlet). If there's any updating, adding, or deleting of the database, then I would use an Entity Bean (or in an even more perfect world, have the JSP call a Session Bean that creates an instance of an Entity Bean to update the database).