简体   繁体   中英

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 .

Now I need to know which tomcat serves my request ?

For that , I need to get the tomcat host and port number and displaying it in the jsp .

This is what I have tried,

<%= "Server Name : "+ request.getServerName()+ " Port : "+ request.getServerPort()%>

But I got the HTTP server port and host only.

How can I show the host and port particular tomcat serve my request ?

You can get the server details using the following API

 InetAddress.getLocalHost().getHostAddress();
 InetAddress.getLocalHost().getHostName();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM