要检查我是否可以连接到名为服务的 Web 应用程序,我打开了与其地址的连接。如何检查是否已连接到此URL/服务?我正在考虑发送某种状态方法(当客户端尝试打开与此 URL 的连接时),以确定客户端是否能够成功建立与服务的连接。但我该怎么做呢?
我正在尝试这样的事情:
final URL url = new URL("http://localhost:8084/service/index.jsp");
final URLConnection urlc = url.openConnection();
InputStream response = urlc.getInputStream();
// Now call a method in the service app that sends a status method...
// .....or can I get away with this ?