October 30th, 2002, 01:31 PM
Using XML files for storing application parameters
I have a problem understanding the concept of <context-param>. I want to write a file "carplan-config.xml" which will store things like:
I dont know how I would then read these in my application. Furhtermore, how do I write the code for reading the
I know I need to use the javax.servlet.ServletContext.getInitParameter() but not sure I how I would implement this.
I have succefully managed to read the init values stored in the <servlet> tag in web.xml, using javax.servlet.ServletConfig.getInitParameter()
Even if I could be pointed to the right direction for some reading on the subject it will be most appreciated. Apologies if teh question is too generic.
October 30th, 2002, 03:28 PM
Gah... This took me forever to find. I knew it was there, just not exactly where....
Anyway, you're going to have to parse your configuration variable yourself. The method you're trying is only going to work with the dtd defined for the server.xml file.
Anyway, there's an easier way than writing your own parser.
Apache project for parsing xml config files.
October 31st, 2002, 10:07 AM
Thansk for the direction, I am currently strugging thorugh the various example to understand how it works. I will try and put any comments here which may help other readers.
For anyone follwoing the thread, here is a better article on the Digester than one recommended on the Jakarat website: