tags:

views:

31

answers:

1

In reference with one of the articles: Howto embed Tomcat 6?

I understood how to embed tomcat in a java application. Thanks for that. However I need to know if there is any elegant method provided by org.apache.catalina.startup.Embedded to check if the container is already started or not?

For example, if I create a batch file for the example given in the link above and click it twice; second time it would fail with JVM_BIND error; tomcat is running.

Please help.

A: 

You could use the example code given on the Tomcat wiki

http://wiki.apache.org/tomcat/HowTo#How_do_I_check_whether_Tomcat_is_UP_or_DOWN.3F_There_is_no_status_command

Note: This doesnt use Embedded

It is trying to connect to the Tomcat ip:port and seeing if it responds.

JoseK
Thanks for the reply. It really helped and I was able to check if tomcat is running!
Yani
@Yani: Glad it helped
JoseK