can anybody let me know the logic they use to get the ip?
The server has to know your IP address to send you a response. That is how the internet works. Presumably they store the IP address for the last account activity in a database somewhere.
When your browser connects to their web site, their HTTP server determines the IP address from the connected socket. That IP address is supplied to Google's web application framework, which stores the IP address in some kind of data store, so that it can be retrieved later. I can't give you much more detail, since I don't work for Google (and even if I did, I probably wouldn'couldn't).
sorry i was talking about the gmail , where you can see a link
"Last account activity: 42 minutes ago at this IP (76.73.38.3). Details".
Is this a real ip.i do not think so. how are they managing to get the ip address , ie. router ip and they are closing off the session opened elsewhere.
request.getRemoteHost();
this method in the request object will return the ip address of the client.