Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 897
Marcus Ericsson Avatar asked Mar 21 '12 21:03

Marcus Ericsson


People also ask

How do I find the IP address of a Web application?

The simplest way to determine the IP address of a website is to use our DNS Lookup Tool. Simply go to the DNS Lookup Tool, type the website URL into the text entry, and select Lookup. You'll notice the search yielded a list of IPv4 addresses that differ from the IPs shown using the other methods.

How do I find my IP address on REST API?

Assuming you are making your "web service" with servlets, the rather simple method call . getRemoteAddr() on the request object will give you the callers IP address.


1 Answers

If you are within the controller, you can do

request.remoteAddress;

Otherwise, you would need to do

Http.Request.current.get().remoteAddress;
like image 53
Codemwnci Avatar answered Sep 30 '22 17:09

Codemwnci