Using a connection pool that's managed by the container is really the only good way to deal with database connections in a web application. Opening a database connection is a relatively slow and heavy operation. Your webapp will become very slow if you open a new connection for each request when the app needs to use the database. It would also make your webapp unable to scale up to large numbers of users, because databases can normally handle only a limited number of connections at a time. A connection pool manages all this for you.
What you'd normally do is setup a connection pool in your container, and then in your webapp get a javax.sql.DataSource object via JNDI, from which you can get the database connection.
Here's a tutorial for how to do that with
Tomcat.