You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Manpreet Singh <ms...@india-today.com> on 2000/08/30 16:53:00 UTC

file not found error !!

Hi,

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" reloadable="true" >
</Context>

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 :
http://mydomain.com/sam/myservlet 
it gives the file not found exception.
I have tried putting the file in all directories from webapps onwards.

Any help is appreciated .
Thanks,
Manpreet.


Re: file not found error !!

Posted by Matt Goss <mg...@rtci.com>.
Manpreet,
use this:
FileReader fr=new
FileReader(getServletContext().getRealPath("/form.html"));
HTH
Matt

Manpreet Singh wrote:

> Hi, 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" reloadable="true" ></Context> 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
> :http://mydomain.com/sam/myservletit gives the file not found
> exception.I have tried putting the file in all directories from
> webapps onwards. Any help is appreciated .Thanks,Manpreet.