users@grizzly.java.net

Re: Determining the client IP

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 27 Nov 2007 17:38:17 -0500

Alan Williamson wrote:
> Okay, i have pretty gleamed everything I need from the Request object
> that I need. Except the remote IP address.

Great :-)

>
> These returns null
>
> req.remoteAddr()
> req.remoteHost()
>
> I am hitting it from the local machine.
>
> Am i looking for it in the right place? If not, then where?

OK that one is a little tricky (and docs completely missing). By
default, we aren't setting those variables to avoid IO level call. So
what you need to add is:

request.action(ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE);
request.action(ActionCode.ACTION_REQ_LOCAL_NAME_ATTRIBUTE);
request.action(ActionCode.ACTION_REQ_HOST_ATTRIBUTE);
request.action(ActionCode.ACTION_REQ_LOCAL_ADDR_ATTRIBUTE);

and then invoke the method you described above.

Let me know if that doesn't work.

Thanks!

-- Jeanfrancois

>
> thanks
>
> a
>