The following is information about the host computer of the client who made the request.
HttpServletRequest.getRemoteAddr()HttpServletRequest.getRemoteHost()
Here is the code you are looking for:
boolean didOriginateFrom(Sting host, HttpServletRequest req) { return req.getRemoteHost().contains(host); }
Both of these methods provide information about the client or the last proxy address that sent the request.
Some servers may return the source address of the client, although the request went through several proxies. Proxies send the address of the immediate client to the server, adding an X-Forwarded-For header. Thus, some servers can process the X-Forwarded-For header values ββand return the original client address.
Here's what the X-Forwarded-For request header looks like
X-Forwarded-For : originalclient, proxy1, proxy2, lastproxy
source share