I have a JEE application which is deployed in two nodes. The problem that I’m facing is when a user chooses to upload a file, if his session created into node1 then the file will be uploaded to that node. Therefore when the same user login again and this time his session is created in node2 and he’s trying to view the file that he had uploaded previously he won’t be able to do so, since the file had been uploaded to node1. Your help is appreciated to overcome this issue.
This is a inherent problem with clustered environment in j2ee. I would suggest storing your files on a seperate shared directory than trying to store it in the nodes. This way it will not have problems in fetching the files from nodes.
Since, the exact nature of your business requirement and type of file you are creating is not known, you can do one of the following:
1) Store the file in a shared space/file system.
2) Convert the file into byte array and store in database (if your database supports it e.g. Oracle). You can retrieve it from the database and recreate the file.
3) If you are generating the file using data and stylesheet then, you can store both data and the stylesheet in the database and render the file when the user requests it.
Thank you all for the valued suggestions.
I think I will go for having separate server to store the files in.