aspose file tools*
The moose likes Servlets and the fly likes How to get server startup info Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get server startup info" Watch "How to get server startup info" New topic
Author

How to get server startup info

Clarence Dy
Greenhorn

Joined: Aug 30, 2006
Posts: 2
Hello,

Is there a way for a servlet to get the time stamp on when the app server (or the JVM) was started? Is this even possible?

I was looking into deploying another app with a servlet that loads on startup. Basically this servlet would just carry the date/time stamp when it started.

My other application would then need to talk to this servlet using other communication methods. This seem like a crude solution and I was hoping to know if there's an easier way. Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Why would you use a servlet for this when you could just use a context listener to place the timestamp in application context?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
Try using java.lang.management.ManagementFactory:

it sounds like you are interested in

ManagementFactory.getRuntimeMXBean().getStartTime();

and

ManagementFactory.getRuntimeMXBean().getUptime();

There are several other beans you can use to get more information. Start by looking at the java.lang.management.*.

Here is another exampe.


Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
Clarence Dy
Greenhorn

Joined: Aug 30, 2006
Posts: 2
Thank you very much, Rashid! This is very helpful.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get server startup info
 
Similar Threads
Retrieving port number on init
load-on-startup in web.xml
load-on-startup with 0 value
Startup classes in iplanet
Is there any way to call servlet?