• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading the ContextParams by Container

 
ramaseshan T
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFSJ Pg:215, Ans for question:2

Which statements about ServletContextinitialization parameters are true?

"They Should be used for data that changes frequently"
This answer is given as incorrect with the reason
ServletContext init parameters are only read at container start-up time


For the ServletContextListener example given in chapter:5, I am able to change the param-value for breed and see it getting reflected in my webpage.(Without redeploying tomcat)

Please clarify:
1. Are the context-init parameters NOT read only once by the container?How come the changes made by me are reflected?
2. The answer for this question should be "They should be used for data that changes frequently"
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please clarify:
1. Are the context-init parameters NOT read only once by the container?How come the changes made by me are reflected?
2. The answer for this question should be "They should be used for data that changes frequently"

The Servlet spec states that context-init parameters are read only once but different containers implement it differently. I think if we encounter this question in the exam then we should go the way it has been given HFSJ. Because the book is written by the authors of the exam.

No, the answer is correct and we should not say that they should be used for data that changed frequently. There may be other containers which donot read the values again after initialization of the application.

I hope it helps!!!

Kapil
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramaseshan - Try an earlier version of Tomcat and you would be able to appreciate the answer. Guess you are using a version that is 5.0 or above.
 
ramaseshan T
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kapil & Subramanian,

Thanks for your help!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic