i need your help .actually i wanna use property file which contains certain information such as database name/user name/host name/Password .
when i tried to use this file in servlet and Java Server Pages(jsp) i get error - FileNotFoundException /plus native method error i placed the property file(db.properties) into WEB-INF,classes folder and also in respect to WEB-INF folder to but i could not access the file in servlet or Jsp.
if anyone can help me please it will be a great help ......
Based on the most common errors when reading data files from servlets, I would bet that the problem is trying to read a file without specifying a complete path and file name. Any code that depends on the "current" directory will fail in a servlet because the servlet container has its own idea of what the current directory is.
Joined: May 27, 2006
well this is my sample code i was using and getting error
and the error which i get after executing above code is as following
Please Help me in order to Solve my problem
waiting for your reply..........Please....
Author and all-around good cowpoke
Or, better, look at getResourceAsStream from the same class. This will return the stream whether you've deployed your app as an expanded file system or from a war fils. The getRealPath method will return null if the app has been deployed as a war file.
It is also worth mentioning that getRealPath and anything that refers to Files will fail if it is deployed as a WAR. Given this, it is usually better to work with URLs and Streams rather than Files as URLs and InputStreams will still work with the WAR deployment.