views:

60

answers:

2

I've got a Java servlet that handles file uploads, but resides in the "intranet" instance of JBoss. It needs to write files to a directory in the "internet" instance of JBoss (on the same machine). The Java servlet can't be moved to the other instance. This is with JBoss 4.2 on a Solaris box.

Is there a way for this to happen? Can there be a shared folder that both instances can see? Thank you.

+5  A: 

If the purpose is to upload files, you can put the files in any common shared directory that both can see (referenced by relative file name, or to a defined location).

If you have potential contention on the files, the way that is usually handled is to write the files to a temporary file name, and rename the file when done. Rename is an atomic operation, unlike writing a file.

I don't see in your question a need for actual communication. For that, EJBs or JMS are the obvious choices in JBoss, but if all you are doing is sharing files, that seems overkill.

EDIT: I'm assuming here that you are writing files using FileOutputStream/FileWriter and the like. In that case, it is a simple case of making a directory or file share that both processes running the respective JBoss instances have rights. If you aren't familiar with Unix file administration and rights, then serverfault.com is the right place to ask about those details.

Yishai
Thanks, Yishai. How do you create a shared directory that both instances can see? Sorry for my ignorance; I thought the only stuff the JBoss apps could see where the files directly under their own instances.
Alex
@Alex: That's a question for http://serverfault.com, it's rather beyond the scope of stackoverflow.
skaffman
+1  A: 

Thus you want to transfer the file between two machines connected by network. The keyword here is FTP or network drive.

You can use FTP (File Transfer Protocol) for this, its name says it all. You could use Java for this and if you like to, then I recommend Apache Commons Net FTPClient. The target machine has to run a FTP server however. You could use under each FileZilla for this.

Alternatively you can at operating system level map a network drive from the target machine in the source machine and just write the file to it as if it is local.

Hope this helps.

BalusC