2

I am sending a hidden iframe form through Javascript form submit. The URL endpoint I send to is local Tomcat server(something like http://localhost:8090/start). The form works great if Tomcat is up and running in my machine, but when I boot up and click on Visualforce page, that triggers this Javascript, I am missing the Javascript form because the tomcat is not launched yet. How we check to see if tomcat application(localhost) is running before submitting a form?

Javascript Code:

function submitForm(url, database, sessionId, employeeNumber, accountId, URL, sysName)
{     
            var iframe; 
            try { 
                iframe = document.createElement('<iframe name="hidden_iframe" style="display:none">'); 
            } catch (ex) { 
                iframe = document.createElement('iframe'); 
                iframe.name='hidden_iframe'; 
                iframe.style='display:none'; 
            } 

            iframe.className = 'NotVisible'; 
            iframe.id = 'hidden_iframe'; 
            document.body.appendChild(iframe); 

            //Create form. 
            var form= document.createElement("form"); 

            //Evaluate incoming url to determine if should initiate webstart 
            if(url == null || url == ""){

                url = "http://localhost:8090/web_start";
                form.target = "hidden_iframe"; 
            }  else {
                //don't launch, only coming through to save variables for later call of same script
                form.setAttribute("target", "formresult"); 
            } 

            form.setAttribute("method","post"); 
            form.setAttribute("action",url); 

            //Add form data. 
            var databaseField = document.createElement("input"); 
            databaseField.setAttribute("type", "hidden"); 
            databaseField.setAttribute("name", "database"); 
            databaseField.setAttribute("value", database); 
            form.appendChild(databaseField); 

            var sysNameField = document.createElement("input"); 
            sysNameField.setAttribute("type", "hidden"); 
            sysNameField.setAttribute("name", "sysName"); 
            sysNameField.setAttribute("value", sysName); 
            form.appendChild(sysNameField); 

            var sessionIdField = document.createElement("input"); 
            sessionIdField.setAttribute("type", "hidden"); 
            sessionIdField.setAttribute("name", "sessionId"); 
            sessionIdField.setAttribute("value", sessionId); 
            form.appendChild(sessionIdField); 

            var employeeNumberField = document.createElement("input"); 
            employeeNumberField.setAttribute("type", "hidden"); 
            employeeNumberField.setAttribute("name", "employeeNumber"); 
            employeeNumberField.setAttribute("value", String(employeeNumber)); 
            form.appendChild(employeeNumberField); 

            var accountIdField = document.createElement("input"); 
            accountIdField.setAttribute("type", "hidden"); 
            accountIdField.setAttribute("name", "accountId"); 
            accountIdField.setAttribute("value", accountId); 
            form.appendChild(accountIdField); 

            var URLField = document.createElement("input"); 
            URLField.setAttribute("type", "hidden"); 
            URLField.setAttribute("name", "URL"); 
            URLField.setAttribute("value", URL); 
            form.appendChild(URLField); 

            document.body.appendChild(form); 
            form.submit();  
}