Write a separate java class with the static getConn() method. u can get the connection object by Connection con = MyConnection.getConn()
or
use context param in deployment descriptor file(web.xml)...