× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I do not like absolute paths either, especially since the test version of
our web server is configured differently from the production version.  (No,
I wouldn't have done it that way, but there it is.)  So here's a line of
code from one of my servlets:

ldap.load(new
FileInputStream(getServletContext().getRealPath("ldap.properties")));

This gets the file from the Application Root directory, whatever it may be.
If you are hazy on what application root and document root are (I admit I
still am), experiment with the getRealPath() method to see what it returns.

PC2

-----Original Message-----
From: Joe Pluta [mailto:joepluta@PlutaBrothers.com]
Sent: January 2, 2002 07:09
To: java400-l@midrange.com
Subject: RE: Servlet Properties


> From: Bruce Jin
>
>  I use absolute location to tell servlet where to find a file.
> File file = new File("/home/myfile.txt").
>
>  To tell servlet which driver to use I use a few lines of code to
> detect if
> the servlet is running on window or on A400. This way I don't
> have to use a
> property file.

While I highly endorse Bruce's use of System properties to determine which
machine you're running on, I do not like absolute paths.  It may be more of
an issue in my environment, because I have several versions of software
running, each on its own application server.  There's a setup file for each
one, stored in the IFS.  Each application has its own document root, and so
I can configure each instance independently.  This is a must, for me.

Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.