如何获得Websphere 6.1的端口号

如何获得Websphere 6.1的端口号

问题描述:

我目前正在开发一个WebSphere 6.1 Web项目。如何获得Websphere 6.1的端口号

在我的java代码中,如何获取当前正在运行的应用程序端口?

+0

你是什么意思与应用端口?你的意思是http端口,就像80,8080端口一样... – 2008-11-05 10:48:16

servlet API为您提供HttpServletRequest中的本地端口。

protected void doGet(HttpServletRequest request, 
     HttpServletResponse response) throws ServletException, IOException { 
    PrintWriter writer = response.getWriter(); 
    writer.write("" + request.getLocalPort()); 
    writer.close(); 
} 

这些端口在节点的serverindex.xml定义(例如,[WAS] /profiles/AppSrv01/config/cells/localhostNode01Cell/nodes/localhostNode01/serverindex.xml)。

<specialEndpoints xmi:id="NamedEndPoint_1214751102556" endPointName="WC_defaulthost"> 
    <endPoint xmi:id="EndPoint_1214751102556" host="*" port="9080"/> 

我不确定WAS JMX支持是否公开此信息 - 您必须检查文档。

如果使用RAD你可以从IDE运行管理控制台,然后发现所使用的所有端口WAS

http://pic.dhe.ibm.com/infocenter/radhelp/v9/index.jsp?topic=%2Fcom.ibm.sca.tools.doc%2Fsamples%2Ftopics%2Fwas_ports.html enter image description here