• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContext initalization parameters

 
Ankur Jain Kothari
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For ServletContext initalization parameters is it a rule that they should be used for only data that changes rarely? i know that these parameters are given in the web.xml and xml file is read only when the app is deployed...does that mean that these they should be used for only data that changes rarely? i am confusd with the word "should"....does all that data that changes rarely become context initialization paramters?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should means, you can do whatever you want, but you don't have to.

The thing about ServletContext is that it is available to your whole web app. So it makes sense to put things in there that rarely change and that are interesting for your whole app, e.g. database information. If these data change 55 times a day, ServletContext is the worst place to put them. If your data is only interesting for one Servlet, then ServletConfig is the right place to put them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic