File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to get local pc file from website? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get local pc file from website?" Watch "How to get local pc file from website?" New topic
Author

How to get local pc file from website?

Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
Hi All,

First, sorry if i put this topic in general not jsp forum.. Feel free to move to another forum, i don't mind at all if bartender thought this is not suitable forum...

I made a web application using java and jsp (servlet). One of web modul need to read file(.txt) from local pc that accessed that web application so the file is not in the server but in each pc client.

How can i get this local file? I put method to get this file in java not directly in jsp.
And i made properties file so the folder path i put in this property file then my java read source from it. But, Every time it's running, always looking at the server not in local pc client..

Any suggestion how to do this?? And i want to put the method not in jsp but directly in java class..

Thanks alot,

Ramses




At the center of non-violence stands the principle of love
.... Martin Luther King, Jr.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

Are you wanting to upload the file from the client machine to the server and process it there or
Are you wanting to read the file and send the contents to the server or
Are you wanting to read and process the contents on the client itself?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
Maneesh Godbole wrote:
Are you wanting to read and process the contents on the client itself?


That's what i want. There's separate application on client that create that textfile. So this web application read the file from client, get the data and show on web page.

Any idea or trick to perform this Manesh???

Thanks
Adam Michalik
Ranch Hand

Joined: Feb 18, 2008
Posts: 128
It wouldn't be nice to allow internet sites to browse your personal computer, would it? What comes to my mind is:
a) let the client upload the file with HTML tag <input type="file"> (I'm sure this input field can be generated by various JSP libraries)
b) use a signed applet to do that programmatically
Maybe there's still another solution.
Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
Thanks Adam for respon..
Yups.. should not allow to browse client pc..But this application implemented internally.
And it's goal to make it automatically, so user no need to search the file and upload.. ( user satisfaction ). In other modul i've made function to get data form server and copy it to client. It can be done in server side.. But still i have no idea how to access client pc to get that file..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

Ramses Butarbutar wrote:..But this application implemented internally.


Like Adam said, signed applets would be one option.
There might also be something possible with java scripts. I am not sure about that though.
As you know, we have dedicated forums for applets as well as html/java script. If you want, I will move this thread to the appropriate forum. Just let me know.
Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
Thanks Maneesh,

I don't think there's possible with java script. There is no way to "read" a directory using javascript. You can't even read a file with javascript.There are security issues in allowing client side scripts to access files on the local machine. For applet i have no idea at all and have no willing to use it.

Each client browser have to verify certificate to access this web application. So i think if i put the method in java class i can get access to get the file. But have no idea to start..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

In essence, you need to sign the jar. When the applet is launched, the user will be asked to confirm if it is OK to allow the applet to read the file.
More details here

Once the user agrees, just treat it as simple file I/O. Open stream, read contents, do stuff, close stream.
Ramses Butarbutar
Ranch Hand

Joined: Jun 16, 2009
Posts: 52
Maneesh Godbole wrote:In essence, you need to sign the jar. When the applet is launched, the user will be asked to confirm if it is OK to allow the applet to read the file.
More details here

Once the user agrees, just treat it as simple file I/O. Open stream, read contents, do stuff, close stream.


Thanks Maneesh,

I will do your suggestion and learn about this signer applet first and it characteristic to give the access. If you don't mind maybe next thread i'll ask your comment for applet what i want to make.
And maybe if you found other way to do this.. please give me news.. I really appreciate it..

Thanks to you too Adam for responding..

Best Regards,

Ramses
 
jQuery in Action, 2nd edition
 
subject: How to get local pc file from website?
 
Similar Threads
Files processing on server
How can i read Serealized objects stream and pdf file stream simuntaneously in one servletconnection
IBM HttpServer and websphere Appserver
Password Protect a File or Directory
PHP chat to write files to my home pc