users@jersey.java.net

Re: [Jersey] How to get Remote IP address/hostname in JAX-RS

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 25 May 2009 07:29:32 +0200

On May 24, 2009, at 10:08 PM, peter_yeung__at_hotmail.com wrote:

> hi
>
> When terminating the REST interface JAX-RS on the server-side, I
> need to get the Remote IP address/hostname (the client IP address)
> in Servlet I can use String ipaddr = req.getRemoteAddr()
> But how can I do simularthing with JAX-RS/Jersey?
>

Inject HttpServletRequest using:

   @Context HttpServletRequest req;

See the following for more details:

   https://jersey.dev.java.net/documentation/1.1.0-ea/user-
guide.html#d4e412

Paul.

> Any help would be much appreciated!
>
> Thanks,
> Peter Yeung
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>