Well, classpath has nothing to do with file reading.  If you were trying to
instantiate a class, then the class would need to be in your classpath, but a
file can be read regardless as long as it is on a reachable filesystem on the
system that your servlet is sitting on.

Properties props = new Properties();
File file = new File("C:\my_path\to_htdocs\hello.properties");
FileInputStream fis = new FileInputStream(file);
props.load(fis);



"wendy.ua" wrote:

> Thanks but I don't like the approach for 2 reasons:
>
> 1. I like to put all properties file into one place.  Since we have
> many tier architecture solution here.  It will be a nightmare if we
> scatter properties files all over the packages.
>
> 2. Putting it in one place allow me to set permission denied easily
> on a directory based using the web server facility.
>
> Thanks any other hints?
> Wendy
>
> Chris Pratt wrote:
>
> > Actually the best way is to put the properties file in the same location as
> > your servlets, then use.
> >
> >     Properties props = new Properties();
> >     props.load(getClass().getResourceAsStream("my.properties"));
> >
> >     (*Chris*)
> >
> > ----- Original Message -----
> > From: wendy.ua <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, April 16, 1999 9:10 PM
> > Subject: How to get servlets to reach htdocs directory
> >
> > > Hi, I put my properties files under my web server (IBM Http Web server
> > > powered by Apache)
> > > htdocs directory, say
> > >     htdocs\props
> > >
> > > Now, I have a servlets that need to read a properties file under this
> > > directory.
> > > How?  I transverse through the classpath inside my servlet, and the
> > > htdocs directory
> > > is not reachable.
> > >
> > > Specifically, I specificied "props\hello.properties" in one of the
> > > initArg of my servlet.
> > > and used class path returned in runtiem to find this file but with no
> > > success.
> > >
> > > Any help is appreciated.
> > > Thanks,
> > > Wendy
> > >
> > >
> > ___________________________________________________________________________
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources: http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> > >
> >
> > ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
Jeremy Grant
Senior Software Engineer
DataMap - Bringing User-Centric Data Access To Your Desktop

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to