users@jersey.java.net

[Jersey] Re: Remote address in ContainerRequest

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 17 Oct 2011 12:36:29 +0200

Hi Christopher,

In case you run within a Servlet container,
you should be able to inject the original Servlet request:

@javax.ws.rs.core.Context HttpServletRequest req;

and then to obtain the address from there: req.getRemoteAddr()

Or do you use any other container?

~Jakub

On 13.10.2011 20:00, Christopher Piggott wrote:
> Hi,
>
> I have a ContainerRequestFilter that implements authentication in a
> largish jersey application. Someone has asked me to print the IP
> address of the remote client in the event of an authentication filter.
> I can't figure out how to do this...
>
> @Override
> public ContainerRequest filter(ContainerRequest cr) {
> ... stuff ...
> }
>
> How can I get the remote address from a ContainerRequest?
>
> --Chris
>