The requirement I have is that my web application should read certain data files(xmls) from the filesystem placed by the user and perform the required execution. The webapp can run on all major application servers(jboss/weblogic/websphere ......) and platforms like windows/linux/aix/solaris
The file system where the users choose to place the file is not known and cannot be hard coded in the app due to difference in file structures. Is there a way through which i can access an environment variable in my app, app server independent, to read the files?
Basically I cannot ask users to have a predefined directory or prefer not to, but then through a variable let my app know that the users will place the file at a certain directory.
Thanks, but using a property file would again mean I am assuming the property file to be loaded at a specific location or ask users to repackage the app with the modified property file. I would like to refrain from enforcing a directory structure or repackaging of the ear at user end.
Is it not possible to ask customer to create a specific environment variable which can be accessed from the app running in the jvm? or some other dynamic way to find that path. Another aspect is that this application would be an extension to a enterprise level app deployed which could have it's home directory different at different client locations. I could use the home directory as a possible source but again I need to find out what that directory would be at each location.
This app cannot be made part of the parent enterprise application since its just an extension which customer may or may not choose to have.
You could certainly ask them to create an environment variable, but remember that the environment variable belongs to the process, i.e. the application server, and not to an individual web application. So for example you would be requiring them to configure their Websphere instance to specify the value of that environment variable.
I leave it up to you to decide whether that is a suitable approach for your customers.
Joined: Apr 25, 2006
Thanks , I will look into this, appreciate the help and suggestions.
But if I ask what would be the recommended way will it be the property file?
Also if we go the route of environment variable is there an issues related to app servers I mean WebSphere behaves differently then Jboss or Weblogic?
I agree with what Paul said. Environment, session or application variables can be a headache. It can be done this way, maybe configuring the variable in the startup script of the server, but you will need to restart the server if the value changes or modified it with System.setProperty(), but the variable will belong to the process and if for some reasons permissions are denied, then a SecurityException will be thrown.
Why not put the value of the directory in a database? Lilke in a parameter's table. It could have the user identifier to accomodate each user (or group of user) environment.