How do I get incoming request IP address in Java Play 1.2.4

Marcus Ericsson picture Marcus Ericsson · Mar 21, 2012 · Viewed 7.9k times · Source

I see in Play! 2.0 there is Http.Context.current() http://www.playframework.org/documentation/api/2.0/java/play/mvc/Http.Context.html#current()

But in Play! 1.2.4 how would I go about getting the current HTTP request's IP Address?

Thanks.

Answer

Codemwnci picture Codemwnci · Mar 21, 2012

If you are within the controller, you can do

request.remoteAddress;

Otherwise, you would need to do

Http.Request.current.get().remoteAddress;