• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting Server IP address from inside the servlet  RSS feed

 
sachin pathak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

How do you get the server IP address from inside the servlet?

Thanks in advance

Sachin
 
TV KUMAR
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the following code,

InetAddress inetAddress = InetAddress.getLocalHost();
String ip = inetAddress.getHostAddress()
 
Nikhil Sagar
Ranch Hand
Posts: 216
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not working on my rhl server.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nikhil Sagar wrote:It is not working on my rhl server.


Have you tried getLocalAddr
 
Nikhil Sagar
Ranch Hand
Posts: 216
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes deepak i tried but it is returning host.
May be problem is apache to tomcat request map. what you think ??
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nikhil Sagar wrote:May be problem is apache to tomcat request map. what you think ??


But in your original post you said "the server". That means there's only one server. But now it turns out there's actually two servers. Would you like to clarify your original post?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes deepak i tried but it is returning host.


Can you elaborate on what you mean by this ? It returns a host string like dc.host.machine ?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!