Home > Java, Java Misc > Determine if you are running in Tomcat

Determine if you are running in Tomcat

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: , , ,
  1. May 1, 2010 at 1:18 pm

    lmao nice stuff dude.

  2. May 1, 2010 at 3:44 pm

    Really nice and impressive blog i found today.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: