This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes difference between request.getRemoteHost() and request.getRemoteAddr() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "difference between request.getRemoteHost() and request.getRemoteAddr()" Watch "difference between request.getRemoteHost() and request.getRemoteAddr()" New topic
Author

difference between request.getRemoteHost() and request.getRemoteAddr()

mohanasundaram muthukannan
Ranch Hand

Joined: May 29, 2008
Posts: 35
Hi,

i need difference between request.getRemoteHost() and request.getRemoteAddr() in jsp?

any one can explain this one?

Regards,
Mohan.M
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

i need difference between request.getRemoteHost() and request.getRemoteAddr()

Is this related to this post ?

Well, getRemoteHost() returns the fully qualified name of the client or the last proxy that sent the request and getRemoteAddr() returns the IP address of the client or the last proxy that sent the request.



SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

BTW, check the Servlet Spec for complete details.
Kenny Kuriakose
Greenhorn

Joined: Nov 20, 2006
Posts: 7
Hi,

request.getRemoteAddr() returns the IP address of the comp whereas request.getRemoteHost() tries to retireve the host name. If host name is empty, then it tries to retrieve the IP address, just like how getRemoteAddr() works.

Thanks,
Kenny Kuriakose
SCJP, SCWCD, SCBCD, SCEA-part 1
mohanasundaram muthukannan
Ranch Hand

Joined: May 29, 2008
Posts: 35
Thanks Kenny Kuriakose



Regards,
Mohan.M
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Java classes, methods and fields are usually explained in detail in the API documents.
I highly recommend you to familarize yourself with finding, reading and understanding the API docs.

Here's the API doc of HttpServletRequest: http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html
 
 
subject: difference between request.getRemoteHost() and request.getRemoteAddr()
 
Similar Threads
About ServerPort, ServerAddr, LocalPort
System IP Address
Can I get the machine name or IP?
server from which page accessed
getRemoteAddr vs getRemoteHost