users@jersey.java.net

Re: [Jersey] Getting ServletContext or real path on filesystem

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 01 Aug 2008 17:33:12 +0200

Hi Rene,

Perhaps you could share a complete example application that i may test?

The ServletContext is obtained from the Jersey-specific Servlet class,
Jersey does nothing special with it, and you should be able to use it
just as you would using a similarly deployed and configured Servlet you
wrote by hand.

Paul.

Rene Wiermer wrote:
> I am using Spring to read a configuration from WEB-INF.
>
> In my normal servlet this works fine:
>
> BeanFactory factory =
> new XmlBeanFactory(new
> ServletContextResource(servletContextProvidedByServlet,
> "WEB-INF/applicationContext-config.xml"));
>
> Here servletContextProvidedByServlet.getRealPath("/") points to
> "/real/fspath/to/webapp"
>
> However, in my REST service in the same application using Jersey, the
> ServletContext is filled differently
>
> Using:
>
> @Context private ServletContext servletContextInjectedByJersey;
>
> This ist not loaded correctly by the ServletContextResource. (I/O
> error).
>
> Reason: servletContextInjectedByJersey.getRealPath("/") gives "/webapp"
>
> Question: is there some way to get the real path from a Resource, or is
> there another way to access files in WEB-INF ?
>
> Thanks in advance,
> Rene Wiermer
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109