users@jersey.java.net

Re: [Jersey] ServletContext?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 11 Mar 2009 13:15:32 +0100

Hi Casper

On Mar 11, 2009, at 1:04 PM, Casper Bang wrote:
> Hello list,
>
> I'm moving from my custom/ad-hoc REST framework over to Jersey, and
> so far I'm impressed by what I see. One small issue I have is
> figuring out how to obtain a servlet context from within a POJO
> resource, in a normal servlet one would simply call
> getServletContext(). Is it still possible to get to this somehow in
> a Jersey application?
>

Yes, do:

   @Context ServletContext sc;

See the following for more details:

   http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features

specifically the sections on "Rules of Injection" and "Use of @Context".

Paul.