The javadoc is a bit confusing t开发者_开发百科o me, and in my local tests it seems like they both return the same thing. What am I missing here?
getRemoteHost
returns the name of the client that sent the request, while getServerName
returns the name of the server that received the request.
It might be the same results in your local tests if you are using two machines on the network, one as a client and one for the server.
I'm not sure where this confusion is coming from, the javadoc is very explicit:
getRemoteHost()
:
Returns the fully qualified name of the client or the last proxy that sent the request.
getServerName()
:
Returns the host name of the server to which the request was sent.
They are both the same thing, because you runs both the client and server at the same machine.
精彩评论