tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nacho <>
Subject RE: file not found error !!
Date Thu, 31 Aug 2000 15:14:48 GMT
Hola ManPreet:

use the getRealPath() method of ServletContext this serves to obtain the
path of a file contained within a webapp, thus you can do :

FileReader fr=new

This method returns a String containing the real path for a given
virtual path. For example, the virtual path "/index.html" has a real
path of whatever file on the server's filesystem would be served by a
request for "/index.html". 

Thislas is an excerpt of tomcat docs, hope this help.

Saludos ,
Ignacio J. Ortega

-----Mensaje original-----
De: Manpreet Singh []
Enviado el: miƩrcoles 30 de agosto de 2000 16:53
Asunto: file not found error !!


im writing a small servlet which opens a file.
I have added the following context path in the server.xml:

Context path="/sam" docBase="webapps/samsung" debug="0"

The code that opens a file is as follows:
FileReader fr=new FileReader("form.html");

Te file is placed in
/usr/local/jakarta-home/dist/tomcat/webapps/samsung/ directory.

when i run the servlet in the following way : 
it gives the file not found exception.
I have tried putting the file in all directories from webapps onwards.

Any help is appreciated .

View raw message