Elaine,

I said "document root directory", which refers to the directory where you
store the documents for the context your are using. By default, under
Windows, this is C:\jakarta-tomcat\webapps\ROOT.

So, you should put your property file here and you should use :

getServletConfig().getServletContext().getRealPath("/topics.properties")

to get your file path.

You should not use the following :

String path = getServletConfig().getServletContext().getRealPath("/");
fileTopics = new FileInputStream(filePath + "topics.properties");

because this is not portable. (It relies on some Tomcat specific behavior
which is not required by the spec.)

Pierre-Yves


-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet API
Technology. [mailto:[EMAIL PROTECTED]]De la part de Elaine Burke
Envoy� : vendredi 13 juillet 2001 16:47
� : [EMAIL PROTECTED]
Objet : Re: properties file in tomcat3.2.1





Pierre - Yves
Thanks very much for the reply.This is the code i have used - which to the
best of my knowledge should do the same thing as yours:
FileInputStream fileTopics=null;
    try
    {
      // open input stream to topics.properties file
      fileTopics = new FileInputStream(filePath +
        "topics.properties");
      Properties propTopics = new Properties();
      propTopics.load(fileTopics);
//    load properties object
However after saving the file in the root of my C:\ (where i have tomcat
installed i'm still getting FileNOtFoundException. Can you throw any light
on the situation for me ??
Kind regards
Elaine
>From: Pierre-Yves Saumont
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
Servlet API Technology."
>To: [EMAIL PROTECTED]
>Subject: Re: properties file in tomcat3.2.1
>Date: Thu, 12 Jul 2001 22:53:42 +0200
>
>Elaine,
>
>here is an example of how to read a property file located in the document
>root directory :
>
> Properties properties = new Properties();
> try {
> FileInputStream propFile = new
>FileInputStream(getServletConfig().getServletContext().getRealPath("/topics
.
>properties");
> properties.load(propFile);
> }
> catch (IOException ioe) {
> // whatever you want
> }
>
>Pierre-Yves
>
>
>-----Message d'origine-----
>De : A mailing list for discussion about Sun Microsystem's Java Servlet API
>Technology. [mailto:[EMAIL PROTECTED]]De la part de Elaine
Burke
>Envoy� : jeudi 12 juillet 2001 21:00
>� : [EMAIL PROTECTED]
>Objet : properties file in tomcat3.2.1
>
>
>
>Can anyone help.......
>
>I need to create a topics.properties file and save it in the filePath
>directory to run my servlet successfully. Does anybody know where that
would
>be in tomcat-3.2.1?? I tried creating it within the localhost8080 folder
>within the work folder but i'm still getting a FileNotFoundException. Any
>suggestions appreciated!
>Thanks
>Elaine B.
>
>
>
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>___________________________________________________________________________
>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



Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

___________________________________________________________________________
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

Reply via email to