0

I am starting a tomcat server in my local for a web application and it takes around 20 minutes to be up and running. I want to check if the web app is up and running and taking any requests via java. Any help? My server is say at localhost:8001/myapp

Thanks in advance.

NorthCat
  • 8,315
  • 16
  • 40
  • 45
Arif Khan
  • 1
  • 3

3 Answers3

0

You can check it through many ways. Like... Set a servlet as start up on-load and inside it keep some loggers which files log messages along with exact time.

Viswanath Donthi
  • 1,725
  • 1
  • 11
  • 12
0

You can add something like localhost:8001/myapp/status to the app that would return information about current status. Then you can just sent http request from java and check the response

Marek Adamek
  • 460
  • 3
  • 7
0
 public String execute(String uri) throws Exception {
    URL url = new URL(uri);
    URLConnection connection = url.openConnection();
    connection.setReadTimeout(1000);
    BufferedReader in = new BufferedReader(
                            new InputStreamReader(
                                    connection.getInputStream()));
    String inputLine;
    StringBuffer outputLine = new StringBuffer();

    while ((inputLine = in.readLine()) != null) 
        outputLine.append(inputLine);
    in.close();
    return outputLine.toString();
}

I guess I will call this method after a certain time period to see if I'm getting a timeout exception of the raw html.

Arif Khan
  • 1
  • 3