• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieving a file from a local disk

 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I hope somebody can help me with this.

I have a program which reads a text file from the client's local drive.
When i tested it in my pc, it ran ok since the server is also here. I am developing in tomcat using localhost. But when I try to use the program in another computer,say for example in computer B, it still reads the text file from my localhost instead of the text file in computer B.

How do I go about this?

Thank you very much in advance for the help
 
Balasubramani Dharmalingam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Bernard,
You cannot read anything from client by using the file path. Whenever u read anything using file path it will take the file from machine where JVM is running. To achieve this you can use file upload option...
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what do you mean by the file upload option?
i will just be reading a text file and not uploading anything

thanks for the quick reply by the way
 
badri nath
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bernard
To read a file from client side and save it into the database you need to upload it into the server..for that you should make use of file upload option. this you can write in HTML..and now to read the content of the text file make use of InputStreams in java.
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Badri.
The file is from the scanner which downloads it to a specific path on the local.
From the local, I then look at that specific path. Even if I upload the file, I would still have to look at the specific path in the local, but it cannot see or read the local drives.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is correct. Neither of the servlet or JSP code running on the server, or the HTML/Javascript code running on the client has access to the client file system.

Imagine the mayhem that would ensue if it could!

As stated by others, the only means you have to get files from the client to the server is to use a file upload control that is initiated by the user.

Unless, of course you resort to applets or fat-client programs that the user must approve.
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Bear.

I guess I will just change the functionality of the program and just have the user upload the files to the server. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic