• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get the IP address of the browser

 
kalyan v
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use either HttpServletRequest.getRemoteAddr() or HttpServletRequest.getRemoteHost()
 
Mirza Galib
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic