>>> Vinay Nath <[EMAIL PROTECTED]> 30-May-00 7:32:08 PM >>>

>I m making a search engine using Servlets.For that i need
>to read the html files from the server.
>Can anyone tell me the easiest way to read a file from the
>server.
>Well I m using FileInputStream class but it throws
>FileNotFoundException even when the file is there on the
>server.

This is probably a problem of naming.

The easiest way to do it is to do this:

   String file=getServletContext().getRealPath(webpath);
   File f=new File(f);
   FileInputStream fin=new FileInputStream(f);
   ....

But you can also do it using:
   ServletContext.getResource(path);

Both methods are well documented in the API docs. Check there for
more details.


Would you like to GPL your servlet when you've done it and have it
released with the GNU-Paperclips servlet container? If so contact me
privately.



Nic Ferrier

___________________________________________________________________________
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