The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Getting the IP address from the request

Posted by Jody Brown on February 15, 2001 at 8:51 AM

Mattias,

In the servlet, use request.getRemoteAddr() - inherited from ServletRequest. This returns the IP address of the agent that sent the request as a String. Also, request.getRemoteHost() will attempt to get the fully qualified host name. If it cant resolve the name however, the IP address will be returned as in getRemoteAddr().

Hope this helps.

Regards,

Jody




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us