ServletContextListener.contextInitialized can look at ServletContext and find out which deployment it is
in web.xml, define the servlet context listener:
<listener> <listener-class>com.path.YourServletContextListener</listener-class> </listener>
and then in YourServletContextListener.java add the contextInitialized method, for example:
public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); String name = sc.getContextPath(); ... }
I believe that you can use this name to select from several data sources that you have configured. depending on how you were deployed, you will create another database connection and get the correct application data.
source share