Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

java.io.FileNotFoundException

 
Greenhorn
Posts: 20
  • 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
 
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
  • 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
 
Greenhorn
Posts: 20
  • 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
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
This is my favorite show. And this is my favorite tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic