Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read and write files from a remote server

 
joseph corner
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic