2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Difference between servletConfig and servletContext in jsp

What is the difference between ServletConfig and ServletContext interface.I am confusing a lot.



  • ServletConfig object is one per servlet class.Object of ServletConfig will be created during initialization process of the servlet.This Config object is public to a particular servlet only
  • Scope: As long as a servlet is executing, ServletConfig object will be available, it will be destroyed once the servlet execution is completed.
  • We should give request explicitly, in order to create ServletConfig object for the first time
  • In web.xml – <init-param> tag will be appear under <servlet-class> tag


  • ServletContext object is global to entire web application.Object of ServletContext will be created at the time of web application deployment
  • Scope: As long as web application is executing, ServletContext object will be available, and it will be destroyed once the application is removed from the server.
  • ServletContext object will be available even before giving the first request
  • In web.xml – <context-param> tag will be appear under <web-app> tag
Answer is