8

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.

biesior
  • 54,554
  • 10
  • 118
  • 177
Marcus Ericsson
  • 1,679
  • 1
  • 11
  • 13

1 Answers1

20

If you are within the controller, you can do

request.remoteAddress;

Otherwise, you would need to do

Http.Request.current.get().remoteAddress;
Codemwnci
  • 51,224
  • 10
  • 90
  • 127
  • 13
    This is correct but if you are using Apache as a front end server you want to look at request.headers.get("x-forwarded-for") – nylund Oct 11 '12 at 09:51