开发者

What is the difference between ServletRequest's getRemoteHost() and getServerName()

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜