Archive

Posts Tagged ‘tomcat’

Determine if you are running in Tomcat

April 29, 2010 2 comments

I have Java libraries that I have written and I like to share between projects. It is called Re-usability. However, in one instance a few lines of code were not to be executed if I was running the code in my servlet on Tomcat. So here is a quick way to find out if you are running within Tomcat:

public static boolean isTomcat() {
String catalinaHome = System.getProperty(“catalina.home”);
return (catalinaHome==null || (catalinaHome.trim().length() > 0));
}

Advertisements
Categories: Java, Java Misc Tags: , , ,