----- Original Message ----- From: "Jerry Atrick" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Wednesday, July 23, 2008 10:51 PM
Subject: retrieving tomcat info from within a war


Is there a way to retrieve tomcat version/info from within a War file? I
actually would prefer this to be web container agnostic, but I'm working
with Tomcat, so that's where I will start.

I know that the manager does almost exactly what I want when going to:
http://localhost:8080/manager/serverinfo

but for the life of me, I can't seem to find it in the src.

They hide it in a property file....

heres the code

       try {
           InputStream is = ServerInfo.class.getResourceAsStream
               ("/org/apache/catalina/util/ServerInfo.properties");
           Properties props = new Properties();
           props.load(is);
           is.close();
           serverInfo = props.getProperty("server.info");
           serverBuilt = props.getProperty("server.built");
           serverNumber = props.getProperty("server.number");
       } catch (Throwable t) {}

The rest of that stuff OS etc is just Java properties

like...

sInfo += "JVM Vendor: " + System.getProperty("java.vm.vendor") + "\n";

etc....

I wonder what would happen if you ran this against Glassfish.... I bet it works... coz TC is probably hiding in there somewhere ;)

agnosticism thru theft... ha ha

Have fun..

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to