I've built some JSP pages on my corporate Tomcat server that successfully attach to DB2 however the performance is pretty bad. I'm using JDBC. I believe it is related to opening and closing the connection multiple times but am unsure how to proceed.

My site uses 3 vertical frames (header, menu, and content pages) accepts several fields from a user and executes a DB2 query based on the data entered. A submit button calls the same JSP and displays the result of the query.

The issue I am having is that it seems that on each load of the JSP the connection seems to be automatically closed. If I open the connection on the first load of the JSP (when called from menu) and don't close it, on the query when the page is called again I get a Null pointer exception.

Sorry to be so wordy but I'm a mainframe programmer and pretty new to the workings of JSP and database connections. I would greatly appreciate any guidance as the best means to handle a database connection that would span multiple JSP pages (or the same JSP called to return results).