• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the IP address of machine where the jsp file is opened

 
Rekha Pai
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I use the following code it gives the IP address of the machine where the tomcat server resides. How to get the address of client machine where the jsp file is opened in the browser.

InetAddress iAddr = InetAddress.getLocalHost();
out.println(iAddr.getHostName());
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletRequest.getRemoteHost() should do the trick.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic