I did not exactly understand your question but if you mean you want to know the server IP that answered the request then you can get it through 'request.getServerName()'.This method is in the interface ServletRequest.If not this and you want to find the Client IP then you can get it through 'request.getRemoteAddr()'. Hope this is of any help. Mounika.
Use ServletRequest.getRemoteAddr(). From the API documentation:
Returns the Internet Protocol (IP) address of the client that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR. Returns: a String containing the IP address of the client that sent the request
Joined: Jan 24, 2001
thanks guys. I also found this one: request.getRemoteHost().toString(); Is this the same as 'request.getServerName()?
Joined: Mar 09, 2003
According to my reading of the API documentation, getServerName() will return the name of the server that is running your servlet and getRemoteHost() returns the name of the client machine that issued the request. Note that getRemoteHost is not guaranteed to return a host name... it may return the same value as getRemoteAddr() if the host name of the client machine is not resolved by the servlet container. I hope this helps, Mark