Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Re: getResourceAsStream() without ServletContext? (http://www.velocityreviews.com/forums/t124510-re-getresourceasstream-without-servletcontext.html)

iksrazal 07-17-2003 01:32 PM

Re: getResourceAsStream() without ServletContext?
 
"Ben_" <nospam@nospam.com> wrote in message news:<3f15b5b8$0$6531$afc38c87@sisyphus.news.be.ea synet.net>...
> 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.

iksrazal

Ben_ 07-17-2003 07:04 PM

Re: getResourceAsStream() without ServletContext?
 
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/my.properties would be accessible. I should
double check, but I can't right now.




All times are GMT. The time now is 12:56 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57