This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes I/O and Streams and the fly likes How to get the IP address of machine where the jsp file is opened Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to get the IP address of machine where the jsp file is opened" Watch "How to get the IP address of machine where the jsp file is opened" New topic
Author

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

Rekha Pai
Ranch Hand

Joined: Oct 30, 2008
Posts: 35
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

Joined: Oct 27, 2005
Posts: 19672
    
  18

ServletRequest.getRemoteHost() should do the trick.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the IP address of machine where the jsp file is opened