Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference Betn. ServletContext and ServletConfig!!

 
Ravi Kumar Ravuru
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,
I would like to know the difference between the Servlet Context and Servlet Config.
Regards,
Ravi
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ServletContext is the over all web application. These include the the parameters you list in the web.xml in the context-param element. (outside any servlet elements you specify) There is a single copy for any and all servlets and jsps running in the web application. Additionally, any Attribute you add to the ServletContext is available to them all and there is one and only one.
ServletConfig is the configuration for a single Servlet or JSP. These include the init-param you list within the servlet element of the web.xml. ServletConfig doesn't have the ability to set or get Attributes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic