File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.io.FileNotFoundException

 
gino mendoza
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm a beginner and i'm pretty sure this is a very basic question.
i have a form in A.html.
the user enters a filename, e.g. C:\list.txt
then control passes on to a JSP page, B.jsp
my code in B.jsp says:
String sFilename = null;
sFilename = request.getParameter("filename");
File myFile = new File(sFilename);
BufferedReader in = new BufferedReader(new FileReader(myFile));
....
However, I get the ff: exception:
java.io.FileNotFoundException: C:/list.txt (No such file or directory)
I am sure the file is there.
What am I missing?
Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If "C:\list.txt" is located on the client machine, keep in mind that your JSP pages are executing on the server. So your JSP is looking for the file on the server and not on the client.
If you are trying to upload a file from the client to the server, you'll need to look into using the file input element in a multi-part form, and coding a servlet to handle the upload.
There are available components to help you do this... search these forums for "file upload" for more info.
hth,
bear
 
gino mendoza
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you're exactly right.
i used the oreilly package to do the file upload, then the JSP reads that uploaded file.
has anyone used the oreilly package before.
will that file that I uploaded reside on the server now or is it only when I used it.
if it got stored, how can I delete it from the server. i don't want to save files on the server, just to rbing them up to ther server, read them and process, then delete/release the file.
thanks
 
Sudarshan Reddy
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any one have the sample code uploading the file to the server from the client machine by using the third party tool..?

thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the JSP FAQ where this is covered.

And, in the future, please start a new post rather then resurrecting a 6-year-old post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic