• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get IP address in servlet

 
Ankush Deshmukh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we get the IP address of the visitor of the site on browser
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The foll. is what was suggested in an earlier discussion.
I have not verified it, but hope it helps. Let me know if you
need the API defi.
Regds.
- satya

if you're actually looking for the IP address of the client machine (visitor as you said) that initiated the request, you can use the
getRemoteAddr method of the ServletRequest class.
 
rgopi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
U can use the method request.getRemoteHost() which returns the ip address. need to import java.net for this.
Bye
Gopinath
---------------------------
Originally posted by Ankush Deshmukh:
How can we get the IP address of the visitor of the site on browser

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic