• 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

Read and write files from a remote server

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a servlet/jsp forum application which supports image upload. For storage space reasons, I would like to write the uploaded images to a different server than the one hosting my web app. Obviously I will also need to read the image data from there.

I am having difficulties sorting out my file permissions - if I fix this will I be able to read and write to absolute file URLs? Or is it more complicated than that... ?

Thanks.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the remote file system is mounted via NFS it should work just like it would locally, assuming all permissions are set appropriately. If the remote file system is accessed via SMB it gets a bit more complicated.
[ August 21, 2006: Message edited by: Ulf Dittmer ]
 
joseph corner
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Do I really need to mount the remote file system?
Is this a basic security feature of java, that it can't write to a folder on a remote web server?

My case is complicated by the fact that my web app is a plugin in a larger application, and I don't have direct access to the web server which runs it. So I'd prefer not to have to set up mounted file systems.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by joseph corner:

Do I really need to mount the remote file system?
Is this a basic security feature of java, that it can't write to a folder on a remote web server?



Java can't magically reach into other machines to read and write to their file systems. There has to be some mechanism in place for it to do so.
A possible alternative is to set up a service on the remote system that does the reading and writing for you.
This could be a web service, FTP server, webdav server, etc...
 
joseph corner
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have ftp running on the remote server, and I could also run a servlet there to read and write the images.
What would people's best solution be, in terms of efficiency and speed?
My first experiments with ftping from my servlet have been unsuccessful....
Thanks.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say go with ftp (instead of something HTTP-based). What problems did you encounter using FTP from within a servlet? Using Jakarta Commons Net I had no issues last time I did it (although it ran in a separate thread, not the servlet itself).
 
joseph corner
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried some basic ftp transactions using com.fooware.net.
The application just hung when trying to connect - no error message. I'll try it again from a stand alone java app., and will take a look at jakarta commons net too..
 
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic