File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

frequently changing init parameters

 
nagalatha mitta
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


thanks in advance
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Remko Strating
Ranch Hand
Posts: 893
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic