javatomcattomcat7embedded-tomcat-7

How to check if app is running on Tomcat 7 embedded?


I have a application that runs as war or in standalone mode with tomcat embedded, I want to check if the application is running as a war within tomcat or if it is running with tomcat embedded.


Solution

  • This is my solution.

    String path = getClass().getProtectionDomain().getCodeSource().getLocation().getFile();
    boolean onWar = path.contains("WEB-INF");