What is the difference between servletConfig and servletContext?

Solution

Servlet Config

Servlet Context

1.ServletConfig object is one per servlet class. 1.ServletContext object is global to entire web application.
2.Object of ServletConfig will be created during initialization process of the servlet. 2.Object of ServletContext will be created at the time of web application deployment.
3.In web.xml – <init-param> tag is used to pass configuration data under <servlet-class> tag. 3.In web.xml – <context-param tag is used to pass configuration data under         <web-app> tag.
4.As long as a servlet is executing, ServletConfig object will be available, it will be destroyed once the servlet execution is completed. 5.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.

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media