Difference between Servlet Config and Servlet Context
Yes, they are extremely basic.
ServletContext - parameter scope is application wide and the parameter can be use to store application session info/ application initialization parameters,etc not specific to a servlet.
Actually the servlet container will create ServletConfig object and pass it to the servlet when it's initialized. Servlet container does object creation for other interface types HTTP request, response etc.
ServletConfig has servlet wide scope. It is defined inside
ServletContext has application wide scope . It is defined outside the
---------------
ServletConfig
---------------
One ServletConfig per servlet
it is used to pass deploy-time info to servlet and configured in the deployment descriptor file, such as web.xml.
it is used to access ServletContext
It is within the Servlet element in Deployment descriptor.
It is accessed by using getServletConfig().getInitParameter("myname");
It is available only to the servlet in which init-param is configured.
--------------
ServletContext
---------------
It returns the current context of a web application running in a particular JVM.
if the web application is distributed,it is one per JVM.
It is used to access the
It is accessed by using getServletContext().getInitParameter("myname");
It is available to any servlet or jsp that is part of web application.
No comments:
Post a Comment