Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds


  Asked By: Adella    Date: Aug 24    Category: Java    Views: 1867

try {
Properties properties = new Properties( );
properties.load( new FileInputStream( new File( "library.properties" )
) );
out.println( properties );
} catch( java.io.FileNotFoundException fnf ) { out.println( fnf ); }


The code written above is a piece of code from my jsp file. I want to load
library.properties file into the properties object.
But I get java.io.FileNotFoundException.

I am deploying my application on BEA Weblogic 7.0 using jdk1.3.1_06. I am
keeping this file in the same directory, where my jsp files are lying.
But I am getting this exception. (I have also tried by keeping the file in
the directory where weblogic is keeping the complied servlet. but it is
still not working. Although I don't any such kind of solution. I have also
tried by all relative paths. I don't want to hardcode the full path of the
file.) I have tried to load a properties file in a simple Test class, there
it works.

import java.io.*;

public class Test {

public static void main( String ar[] ){
File file = new File( "A.txt" );
System.out.println( file );

It works in the above code. here A.txt at the same place, where Test class

please give me some solution.



1 Answer Found

Answer #1    Answered By: Carl Woods     Answered On: Aug 24

You are developing a JSP page, which can be accessed
thru the web server. You've to use the URL to access
the local file, even if it is in the same folder

Didn't find what you were looking for? Find more on java.io.FileNotFoundException Or get search suggestion and latest updates.