I have several mini wars that are modules of a larger application running on a Tomcat 6.0 server. I'm doing it this way, instead of putting all modules in one war, because different installations need different modules. I'm starting to hit a roadblock in which I need to know what other mini wars are installed in the server. Is there a way to get the list of all installed wars/contexts in the Tomcat 6.0 server?
                
                A: 
                
                
              
            From any one of the web applications, it is not possible.
You can use the tomcat management console which, if installed, you can access at /manager/html on the server. This will list all of the applications installed.
                  stevedbrown
                   2009-06-24 16:23:52
                
              
                +1 
                A: 
                
                
              
            I've managed to get a workaround to this problem since the "mini wars" that I will create can share a lib at the common class loader level in tomcat.  The trick would be to use an ApplicationListener (located in the common class loader) that does the following:
public class ApplicationListener implements ServletContextListener {
  private static Map<String, ServletContext> contexts = 
    new HashMap<String,ServletContext>();
  public void contextInitialized(ServletContextEvent event) {
    ServletContext context = event.getServletContext();
    if (context.getContextPath().length() > 0)
      contexts.put(context.getContextPath(), context);
    context.setAttribute("myapps", applications);
  }
}
When a Context is created it registers as a ServletContext in the static map.  This static map is then shared between all contexts through the Context variable myapps.  Anytime I need access to other contexts I can do the following:
ServletContext namedcontext = 
  ((ServletContext) ServletContext.getAttribute("myapps")).get("/namedapp");
Hope it helps somebody.
                  rmarimon
                   2009-08-02 18:20:35