Creating a JNDI DBCP Connection Pool
Create a new folder called META-INF (in capitals) in your application, at the same level as WEB-INF.
Copy the source code below into a file called context.xml
Your application directory structure will look something like this:
JAKARTA-WEBAPPS
JAKARTA-WEBAPPS/JNDIApp
JAKARTA-WEBAPPS/JNDIApp/test.jsp
JAKARTA-WEBAPPS/JNDIApp/WEB-INF
JAKARTA-WEBAPPS/JNDIApp/WEB-INF/web.xml
JAKARTA-WEBAPPS/JNDIApp/WEB-INF/lib
JAKARTA-WEBAPPS/JNDIApp/WEB-INF/lib/jstl.jar (required for using JSTL only)
JAKARTA-WEBAPPS/JNDIApp/WEB-INF/lib/standard.jar (required for using JSTL only)
JAKARTA-WEBAPPS/JNDIApp/META-INF
JAKARTA-WEBAPPS/JNDIApp/META-INF/context.xml
Note: you will need to customise this file with your own database name, username and password.
Source Code (Copy and Paste):