tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johnny Kewl" <j...@kewlstuff.co.za>
Subject Re: retrieving tomcat info from within a war
Date Thu, 24 Jul 2008 09:56:28 GMT

----- Original Message ----- 
From: "Jerry Atrick" <jjunos@gmail.com>
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message