users@jersey.java.net

Re: [Jersey] How can I get the current directory of my application?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 27 Nov 2008 17:12:56 +0100

On Nov 27, 2008, at 4:49 PM, Marcelo Emanoel B. Diniz wrote:

> Hello people I'm developing my first resources and would like to
> know how could I get the current directory of my application. For
> instance:
>
> if I simply use new File(); What I get is C:\tomcat\bin
> I wanna catch the C:\tomcat\web-apps\myApp
>
> is it possible? with servlets I could pass a parameter or get it
> through the request....
>

Inject the following in your resource class:

   @Context ServletContext sc;

(ServletConfig, HttpServletRequest/Response are also supported).

Paul.