Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServeltContext vs ServeltConfig

 
s khosa
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Both ServletContext and ServletConfig objects have getInitParamter(String str) and getInitParamterNames() methods deifned.
I am wondering which one do we use to retrieve init parameters and why?
 
Ken Januski
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContext is for all servlets that are in the web-app. So you might have many servlets all using information that is there, for instance deveoper info, version number of web-app, etc. ServletConfig is for just one servlet so you would have init parameters for just that specific servlet.
 
Andy Wong
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContext is used to store application wide init. parameters such as database connection string or log file name. ServletConfig is used to store parameters only to a specific Servlets. For example, constants use in a servlet.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!