This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
hi friends In HFSJ book page 153-they have given that"if the values of your init parameters are going to change frequently,you're better off having your servlet methods get the values from a file or database"
if anybody knows "how to write a code to store init parameters in a file or database and to get init parameters from a file or database" please let me know
Init parameters are something like deploy-time constant. You can't change them. If you wish to change them, you will need to redeploy your web app.
Storing init parameters to database for file is surely possible, but why do you want to do that?
Actually what the book is trying to say is that if you have values that change frequently, use database or a file to retrieve those values and not use init parameters and store them into database/file.
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
I store the most of my init parameters in a database, because in a database you can easily search, etc. It could also be that I've more experience with databases.
By the init method you could get the values by a helper class which gets you values from the database. Mostly I use a query which stores the values in a HashMap from which you can retrieve your init values by a getting method which uses the HashMap for getting the values.
A big advantage is that you can store your parameters user dependent and the user can change them if you want to.