users@jersey.java.net

Re: [Jersey] _at_GET and _at_Context HttpServletRequest

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 11 Jun 2009 14:46:09 +0200

On Jun 11, 2009, at 2:29 PM, Igor Minar wrote:

> Hi there,
>
> I'm curious as to why it is illegal to inject request as a method
> parameter for methods annotated with @GET.
>

You can do this:

   @GET
   public String get(@Context HttpServletRequest hsr) {
     String remoteAddress = hsr.getRemoteAddr();
   }

Does the above not work for you? if so what version of Jersey are you
using?

Paul.


> I'm trying to get the remote ip address of the client for my GET
> method and I can't figure out how to do it without the request
> instance.
>
> Am I overlooking something?
>
> thanks a log!
>
> /i
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>