Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I need to save files in my web app and I need to save them outside the web application folder so I don't lose them during new deployments.
Now I am saving them inside getServletContext( ).getRealPath("/") + "data" folder and they end up inside approot/data folder.
How I can point to some other folder on disc not related to the app server.
Is there solution which would work for both Windows and Linux, since my development is Windows and production is Linux.
If the folder location will differ between where the app is deployed, you could specify the path as a context param in the deployment descriptor and set is as appropriate for each deployment. If you'd rather not mess with having to change web.xml every time (I know I don't), you could put this type of information in an external properties file that the web app reads upon startup (a context listener is great for this) and stores in application context.
I would just like to ask you one more question (style wise).
Should I put some dev or production parameter too in the properties file and in application I ask
if it is production to go to certain folder or if it is developemnt to go to diffferent folder?
I have never knew the best way to do these kind of things (different parameters for production, staging and development) nicely.
That's the beauty of having an external properties file that is not part of the web application. You can have one file on the dev system that specifies one folder, and a file on the target production system that defines another.
I am sorry to bother you more, but I would like to clarify this once for all and it seems that you can
hep me.
When you say external property file is that file part of the build (somewhere in webapps/myapp/some_config_folder ) or it is outside of myapp folder.
If it is outside myapp folder where is the best place for it to be?
If it is outside myapp folder where is the best place for it to be?
Depends how you are obtaining the properties. If you are letting the class-loader do the work, then anywhere in the classpath is fine. For Tomcat 6, you could drop the properties file in the lib folder (common/lib for Tomcat 5).
Lorana Berd wrote:Is there solution which would work for both Windows and Linux, since my development is Windows and production is Linux.
It´s useful to know that paths like "/usr/appserver/files" works on both environments. In Windows it actually points to the desired directory at the same disk as where the server runs. If it is for example C:\, then it actually points to C:\usr\appserver\files.
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
Free, earth friendly heat - from the CodeRanch trailboss