> In this case, the class and the resource were packaged together:
> that should
> mean you could use the same class-loader for both, no?  (Assuming, of
> course, the user didn't monkey around with your classes,...)

this may however not be guaranteed at all times. especially if you monkey:ed
around with your classpath, hence it is safer to use the context class
loader instead.
that way you don't have to worry, better to play it safe, don't you agree?

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
[EMAIL PROTECTED]
www.filip.net

> -----Original Message-----
> From: William Kaufman [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 23, 2001 10:46 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Accessing a packaged file
>
>
> > > Or more succinctly;
> > >
> > > this.getClass().getResourceAsStream(String);
>
> Or, more succinctly,
>
>     getClass().getResourceAsStream(String);
>
> > nope, this is not a good approach at all!
> >
> > if the class "this" is loaded by the system class loaded, you
> > are screwed,
> > because the system classloader doesn't point to the WAR directories
>

>
>                                                             -- Bill K.
>
>
> > -----Original Message-----
> > From: Filip Hanik [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, April 23, 2001 10:13 AM
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: Accessing a packaged file
> >
> >
> > > Or more succinctly;
> > >
> > > this.getClass().getResourceAsStream(String);
> >
> > nope, this is not a good approach at all!
> >
> > if the class "this" is loaded by the system class loaded, you
> > are screwed,
> > because the system classloader doesn't point to the WAR directories
> >
> > Filip
> >
> >
> > ~
> > Namaste - I bow to the divine in you
> > ~
> > Filip Hanik
> > Software Architect
> > [EMAIL PROTECTED]
> > www.filip.net
> >
> > > -----Original Message-----
> > > From: Samson, Lyndon [IT] [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, April 23, 2001 9:47 AM
> > > To: '[EMAIL PROTECTED]'
> > > Subject: RE: Accessing a packaged file
> > >
> > >
> >
> > >
> > >
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Filip Hanik [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, April 23, 2001 5:28 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: Accessing a packaged file
> > >
> > >
> > > Thread.currentThread().getContextClassLoader().getResourceAsStream
> > >
> > > picks up files in your WEB-INF/classes or WEB-INF/lib inside of a
> > > jar or zip
> > > Filip
> > >
> > > ~
> > > Namaste - I bow to the divine in you
> > > ~
> > > Filip Hanik
> > > Software Architect
> > > [EMAIL PROTECTED]
> > > www.filip.net
> > >
> > > > -----Original Message-----
> > > > From: Jim Downing [mailto:[EMAIL PROTECTED]]
> > > > Sent: Monday, April 23, 2001 9:09 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Accessing a packaged file
> > > >
> > > >
> > > > Hi,
> > > > I'm trying to get a servlet to access a text file that
> > has been packaged
> > > > with the servlet in a .war file. Is it possible to access the
> > > file without
> > > > knowing it's absolute path when deployed, and if so how?
> > > >
> > > > jim
> > > >
> > > >
> > >
> >
>

Reply via email to