File conf = new File(catalinaBase, "conf");
File serverXML = new File(conf, "server.xml");
SAXReader reader = new SAXReader();
Document doc = reader.read(serverXML);
Element serverElement = (Element) doc.selectSingleNode("/Server");
String serverPort = serverElement.attributeValue("port", "8005");
String shutdownCommand = serverElement.attributeValue("shutdown", "SHUTDOWN");
// send shutdown command to specified port
Socket socket = new Socket();
socket.connect(new InetSocketAddress("127.0.0.1", Integer.parseInt(serverPort)), 1000);