[英]how to get tomcat host and port number in load balancing?
I have successfully configured my java
project with load balancing
with HTTP server
two tomcat
. 我已经使用
HTTP server
2 tomcat
load balancing
成功配置了java
项目。
Now I need to know which tomcat serves my request ? 现在我需要知道哪个tomcat服务于我的请求?
For that , I need to get the tomcat host and port number and displaying it in the jsp
. 为此,我需要获取tomcat主机和端口号并将其显示在
jsp
。
This is what I have tried, 这就是我尝试过的
<%= "Server Name : "+ request.getServerName()+ " Port : "+ request.getServerPort()%>
But I got the HTTP server
port and host only. 但是我只有
HTTP server
端口和主机 。
How can I show the host and port particular tomcat serve my request ? 如何显示特定于主机和端口的tomcat服务我的请求?
You can get the server details using the following API 您可以使用以下API获取服务器详细信息
InetAddress.getLocalHost().getHostAddress();
InetAddress.getLocalHost().getHostName();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.