Check if Tomcat was running

I am embedding Tomcat 7 in my Java application. In the constructor, I set the variable:

this.tomcat = new Tomcat();
this.started = false;

Then I have another method that is called at a later point to start it:

this.tomcat.start();
this.started = true;

I use a variable this.startedto track if I started the server. It means that the server state is stored several times (inside Tomcat and again in a variable). Ideally, I would just like to use the Tomcat API to get server status, but I could not find a way to do this.

The best alternative I found is trying to open a connection to the server. This seems to be a slow (on a processor time scale) and resource inefficient solution.

+3
source share
1 answer

this.tomcat.getServer() GetState();.

this.tomcat.getServer() getStateName();.

, , , , ..

+2

All Articles