Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: getResourceAsStream() without ServletContext?

Thread Tools

Re: getResourceAsStream() without ServletContext?

Posts: n/a
"Ben_" <(E-Mail Removed)> wrote in message news:<3f15b5b8$0$6531$(E-Mail Removed)>...
> What about this.getClass().getClassLoader().getResourceAsStre am() ? If the
> class is used loaded by a servlet, your class will WEB-INF/classes in its
> classpath. In fact, your class will have the same classpath as the
> classloader that loaded you.
> Alternatively, you can add a setClassLoader(ClassLoader cl) method on your
> generic class and use the classloader the client tells you to use.

Tried that, thanks though. The problem in this case is that only
WEB-INF/classes is in the classpath - I need to access WEB-INF/somedir
.. Any class-based solution can't access a non-classes dir under
WEB-INF, I'm thinking.

Reply With Quote
Posts: n/a
I used to print out all servlet context variables and IIRC, I saw one with
the servlet classpath. I think the root directory of the WAR file is in the
classpath. Thus WEB-INF/somedir/ would be accessible. I should
double check, but I can't right now.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get a frame without titlebar and without any controls ontitlebar Java 2 02-16-2008 03:11 AM
PythonWin: any way to delete all objects without exiting and without doing it with "del"? Python 5 03-03-2006 05:12 PM
How to store session ID without cookies and without "Cookieless=True" Paul W ASP .Net 4 06-02-2005 09:34 AM
How to allocate mem without using malloc() & free without using free() Rajshekhar C Programming 5 03-29-2005 06:03 PM
open a new window without javascript and without hyperlink Dan ASP .Net 8 11-24-2004 08:10 AM