Read values from WEB.XML file or STRUTS-XML.config FILE
Posted on 2005-04-24
I have a .NET background so I need some advice on reading a value from either the
WEB.XML File or the STRUTS-XML.config file. I am developing with STRUTS
Problem: I want to keep a MySQL database connection string in some XML file.
I know I can use either the WEB.XML or the STRUTS-XML.config file.
Question 1: Is it true that if I use the WEB.XML file approach:
?? Is it true that only a servlet - defined to in the WEB.XML file such as:
??can read the WEB.XML values?
I tried this approach and get a null pointer exception. using getServletContext().
I know that STRUTS really doesn't like this approach, but I don't want to read the
XML value from the Controller / Action Servlet. Don't like this approach.
I'd rather my 'DataAccess.DataRequestor' class call some XML file directly (could be anywhere) to get the DataBaseConnection string - (at start up).
.....please advise - I'd like to try both approaches once just for the knowledge