init-param web.xml, URL- . , MySQL :
<init-param>
<param-name>DB_URL</param-name>
<param-value>jdbc:mysql:///MY_DB</param-value>
</init-param>
Then get this value in your web application (in the servlet) using something like this:
String myDbUrl = getServletConfig().getInitParameter("DB_URL");
In JSP files, you can get the value as follows:
String myDbUrl = config.getInitParameter("DB_URL");
source
share