What is the use of ServletConfig and ServletContext..?

Showing Answers 1 - 4 of 4 Answers

Senthilrajan

  • Jun 17th, 2005
 

An interface that describes the configuration parameters for a servlet. This is passed to the servlet when the web server calls its init() method. Note that the servlet should save the reference to the ServletConfig object, and define a getServletConfig() method to return it when asked. This interface defines how to get the initialization parameters for the servlet and the context under which the servlet is running. 
 
An interface that describes how a servlet can get information about the server in which it is running. It can be retrieved via the getServletContext() method of the ServletConfig object. 

  Was this answer useful?  Yes

Pradeepta

  • Jun 5th, 2007
 

ServletConfig and ServletContext are used to pass technical information from outside to the servlet. e.g. JDBC driver classes. ServletConfig is limited to the Servlet only and the ServletContext is spread over the complete web application. So ServletContext object can be accessed by all the Servlets present inside the webapplication

  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