![]() |
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 |
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.