How to get Websphere 6.1 port number

六月ゝ 毕业季﹏ 提交于 2019-12-24 06:44:54

问题


I'm currently working on a WebSphere 6.1 Web Project.

In my java code, how can i get the current running application port?


回答1:


The servlet API gives you the local port in HttpServletRequest.

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

The ports are defined in the node's serverindex.xml (e.g. [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"/>

I'm not sure if the WAS JMX support exposes this information - you'd have to check the doc.




回答2:


If you use RAD you can run administrative console from IDE and then discover all the ports used by WAS

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



来源:https://stackoverflow.com/questions/264764/how-to-get-websphere-6-1-port-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!