ServletContext |
ServletConfig |
ServletContext represents the whole web application running on a particular JVM and common for all the servlet. |
ServletConfig object represents single servlet. |
It is just like a global parameter associated with the whole application. |
It is the same as the local parameter associated with a particular servlet. |
It has application-wide scope so define outside servlet tag in the web.xml file. |
It is a name-value pair defined inside the servlet section of web.xml files so it has servlet wide scope. |
getServletContext() method is used to get the context object. |
getServletConfig() method is used to get the config object. |
To get the MIME type of a file or application session related information is stored using a servlet context object. |
The shopping cart of a user is a specific to particular user so here we can use servlet config. |