I use JBoss AS 7 and Struts 2. My problem is I need to save config file(database settings) on the disk, like a simple myconfig.xml or something like this. One of the most big problems, that I have .war file and cannot to save inside /WEB-INF(hah, but I think it'd be good solution). Of course, I don't want, that somebody will be able to read my config from network, only for local usage. Just imagine, you go to http://yourhost//install.action, then you fill out your database settings(username,password,host,port), my install.java(action class in struts.xml) and then it generates databaseSettings.xml and it need to retain somewhere. And the place shouldn't be available from network.
If I use tomcat without .war or .ear files, I can do it easy:
write:(code in servlet or in my case, in POJO class of struts2 action)
What can I do? I wanna use .war, but I need to use config files. Where can I retain my configs in JBoss AS 7?
Most of my database setting are done to set up a database connection pool, and that's something that's part of the webapp server, not of the webapp, so I just configure the pool and there's nothing that would or could go into or be accessed by the WAR.
One or 2 specialized apps do need stuff like that, and of course, there's lots of other config data besides databases that it's useful not to have packaged inside the war. So I normally put that in a file, which can be a java properties file, JSON, XML, or whatever.
Because I'm used to environments where I develop on Windows and run production on Solaris or Linux and I have a firm policy of one WAR for all instances, I don't hard-code the location of my config files in the WAR, however. I use web.xml config parameters that are backed by the server's JNDI directory and do a JNDI lookup to get the path of the file to open and read.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.