Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • 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
  • 0
  • 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: 20381
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletRequest.getRemoteHost() should do the trick.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic