users@jersey.java.net

Re: [Jersey] Loading files during initialization

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 19 Oct 2009 22:29:26 +0200

On Oct 19, 2009, at 8:05 PM, Tatu Saloranta wrote:

> On Sat, Oct 17, 2009 at 6:45 PM, Marco FAQ <marcofaq_at_gmail.com> wrote:
>>
>> I am giving Jersey + Tomcat a try for developing a web service
>> first time.
>>
>> The service needs to read/load up a bunch of files (data source) in
>> to
>> memory during initialization. What's the easiest way to do this? The
>> location of the files should be configurable (part of web.xml?).
>
> This sounds like a basic Servlet container question, so maybe try
> Tomcat mailing list?
>
> There are multiple ways to achieve this; usually you'd create a
> context listener or dummy servlet to kick of pre-loading.
>

Yes, and then you can inject ServletContext to get access to that stuff:

   @Context ServletContext sc;

to get access to such information.

Paul.