• 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic