my dog learned polymorphism*
The moose likes Sockets and Internet Protocols and the fly likes how to get the IP address of the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how to get the IP address of the browser" Watch "how to get the IP address of the browser" New topic
Author

how to get the IP address of the browser

kalyan v
Greenhorn

Joined: Jun 27, 2001
Posts: 5
I'm developing an web application, in that application, I have to restrict some users by identifying their ip address. How can I get clients IP address?
Thanks in advance.
Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
You can use either HttpServletRequest.getRemoteAddr() or HttpServletRequest.getRemoteHost()
Mirza Galib
Greenhorn

Joined: Jun 02, 2002
Posts: 12
If you are not using servlets of JSP's and you are working with your own server written in java.
The information you get from your socket object that is returned from your ServerSocket object Accept() method contains information about the remote host . You have to call socket object getInetAddress() method to get the ip address.
If you are using Servlets or JSP's then call getRemoteHost() method on HttpServletRequest object that your servlet/JSP container providing u .


"Hain aur bhee duniya mein sukhanwar bahut acche.<br />Kehte hein ke Galib ka hai andaz-e-bayaan aur."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the IP address of the browser
 
Similar Threads
IP address
api to remote internet IP and local IP address of my computer
Java /Oracle (IPAddress)
can we detect location if GPS is not accesible
Editing URL of an Application