【问题标题】:How to find apache server is running or not from another apache server? [closed]如何从另一个 apache 服务器查找 apache 服务器是否正在运行? [关闭]
【发布时间】:2013-03-15 05:08:27
【问题描述】:

我有两个 apache 服务器。一台 apache 服务器正在运行。另一个 apache 没有运行。从运行 apche ,如何找到第二个 apache 是否正在运行?我想要jsp代码..

【问题讨论】:

  • “检查 apache 服务器是否正在运行”是什么意思?进程到了吗?它是否响应请求?是否可以从另一台特定服务器访问?

标签: java ajax apache jsp tomcat


【解决方案1】:

我不明白你的意思,也许你想通过套接字连接 apache 服务器。

<%@ page contentType="text/html" import="java.io.*, java.net.*" %>

<% 
        try {
            Socket s = new Socket("another.apache.com", 80);

            BufferedReader in = new BufferedReader(new 
            InputStreamReader(s.getInputStream()));
            PrintWriter socketOut = new PrintWriter(s.getOutputStream());

            socketOut.print("GET /index.html\n\n");
            socketOut.flush();

            String line;

            while ((line = in.readLine()) != null){
                out.println(line);
            }

        } catch (Exception e){}
%>

如果没有异常,说明你的另一台apache服务器正在运行,否则处于离线状态。

【讨论】:

  • 谢谢你。你给了我预期的答案。
猜你喜欢
  • 2014-02-12
  • 1970-01-01
  • 1970-01-01
  • 2010-09-06
  • 2015-08-10
  • 2011-07-04
  • 1970-01-01
  • 2019-12-29
  • 2020-11-01
相关资源
最近更新 更多