Henning Meinhardt wrote:

> Hi everybody.
>
> Can a servlet get the path it was loaded from by the servlet container? I
> want to have a property file lying in the same directory as the servlet und
> have the servlet access the file without using a servlet parameter of the
> container pointing to the directory where the file lies.
>

For this purpose, your best approach would be to use
ClassLoader.getResourceAsStream() to do this -- it will work even if the class was
loaded from a JAR file.  See the JDK JavaDocs for more information on this call.

>
> Thanks in advance.
> Henning Meinhardt
>

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to