This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The short story is: I'm looking for a way to read/parse struts-config.xml from inside an action. Obviously I will use an XML parser library like Xerces ... the question is where do I look for the struts-config.xml file from within an action. Is it even available from an Action? Any help would be greatly appreciated!
The long story is: I am configuring multiple data sources in the struts-config file (each installation requires X data sources, the number of data sources vary from installation to installation so struts-config.xml data sources are different in each installation.) I need to get a list of the data-sources from the struts-config.xml file so that I can display appropriate choices.
ActionServlet does have a dataSources HashMap variable with all of the keys and values, unfortunately it is protected so I don't have access to it (and there are no "getters" for it.)
ActionServlet exposes findDataSource(), but you need to know the key name of the data source (which I don't)
So... the goal is to just parse out struts-config directly and grab the info I need. The problem is if it's not in the web area I can't URL to it (and I can't put it in a public area because it contains passwords!) So, how do I get to it?
Thanks for any help/advice!
William Frederico<br />Logic Mountain Software<br /><a href="http://www.logicmountain.com" target="_blank" rel="nofollow">http://www.logicmountain.com</a>
Joined: Oct 29, 2004
Well, I knew if I looked hard enough I would find it and I did! Beat yas all to the draw
Anyway, it looks like the web server (at least Tomcat) provides a jndi key to the struts-config file. So, to get a reference to struts-config that you can read and parse, you can do this: