aspose file tools*
The moose likes JSP and the fly likes retrieving a file from a local disk Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "retrieving a file from a local disk" Watch "retrieving a file from a local disk" New topic
Author

retrieving a file from a local disk

Bernard Sigmund Gustav
Ranch Hand

Joined: Dec 20, 2005
Posts: 170
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

Joined: Dec 06, 2004
Posts: 116
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...


Balasubramani SD,<br />SCJP 1.4,SCWCD 1.4,SCJP 5.0<br /><a href="http://sd.balasubramani.googlepages.com" target="_blank" rel="nofollow">www.sd.balasubramani.googlepages.com</a>
Bernard Sigmund Gustav
Ranch Hand

Joined: Dec 20, 2005
Posts: 170
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

Joined: Dec 21, 2005
Posts: 57
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

Joined: Dec 20, 2005
Posts: 170
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

Joined: Jan 10, 2002
Posts: 61413
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bernard Sigmund Gustav
Ranch Hand

Joined: Dec 20, 2005
Posts: 170
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrieving a file from a local disk