There's nothing stopping you from using data sources programmatically instead of declaratively. Having declarative approach is preferable because you code can concentrate more writing business logic as opposed to infrastructure services.
If we don't specify it in web.xml
is there any other way we can acquire datasource connection in our web application?
In Tomcat 5.5.8, you can put this tag within the innermost tag (<Host> tag)
[ July 13, 2006: Message edited by: Naseem Khan ]
You could put it in a properties text file if you have a lot of other properties you need to store. It doesn't matter where you put it (web.xml, text file, or setup a database connection pool on the server*) as long as its not hardcoded into the java file.
Do you mean this?
We have to create a datasource in the Application server and bind it with a JNDI name. The Jndi name can be given either in the web.xml or a properties file.