• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get local pc file from website?

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ramses Butarbutar
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic