What is the difference between ServetConfig and ServletContext..?

Showing Answers 1 - 6 of 6 Answers

Sanjay Ranga

  • Jun 20th, 2005
 

Servlet Config as the name suggests, provides Servlet specific configuration information to a particular servlet. For Example :- the information that u specify in the web.xml file like this 
 
 
... 
 
 
 
 
Each servlet will have its own servlet config object, which will be specific to that servlet. 
 
ServletContext 
-------------- 
It provides application view to all the servlets. There is one ServletContext per JVM for one application. 
It also provides methods to access application wide parameters specified 
in .... tag in web.xml. 
 
These will be accessible to all the servlets. 
 

  Was this answer useful?  Yes

Sanjay Ranga

  • Jun 20th, 2005
 

Servlet Config as the name suggests, provides Servlet specific configuration information to a particular servlet. For Example :- the information that u specify in the web.xml file like this 
 
 
... 
 
 
 
 
Each servlet will have its own servlet config object, which will be specific to that servlet. 
 
ServletContext 
-------------- 
It provides application view to all the servlets. There is one ServletContext per JVM for one application. 
It also provides methods to access application wide parameters specified 
in .... tag in web.xml. 
 
These will be accessible to all the servlets. 
 

  Was this answer useful?  Yes

gokulakrishnan

  • Sep 28th, 2005
 

SevletConfig is used to give the information during the initializing period.

ServletContext is  used for thye communication between the servlet and the servletcontainer thatis to give MIME types.

ServletContext is used to access other environments thatis accessing other servlets with in the same server.

ServletContext is used to share all the servlets.

In servlet interface we are having the servletcontext and servletconfig within servletconfig we are having servletcontext.    

  Was this answer useful?  Yes

surikvs332

  • Jun 22nd, 2010
 

ServletConfig:  This is mainly to get the configuration parameters int your serlet. With this we can get the configuaration data which we menstioned in the web.xml file.

ServletContext: This is for entire application and This will share the information to entire application. Means ServletContext maintains the environmental information of the application.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions