Java Servlet Programing Laungage

Java Servlet Projects

Servlet Project 3

Java Servlet : Methods of ServletConfig interface
Previous Home Next
getServletContext() is used to obtain the reference of sevletContext object.

Syntax
	public ServletContext getServletContext();
	
getInitParameter() is used to obtain the value of initialization parameter.

 

Syntax
	public String getInitParameter(String name);
	
getInitParameterNames() returns an enumeration for the name of initialization parameters stored in ServletConfig.

Syntax
	public Enumeration getInitParameterNames();
	
Similarities and Difference between servletContext and ServletConfig

Similarities

  1. Both these interfaces are in same javax.servlet package
  2. The vendors of Web Server (which support servlet technology) provide the implementation classes for theses two interfaces

Differences :

  1. Only one ServletContext object will existed for one Web Application . One Servlet Configuration object existed per a Servlet in a Web Application.
  2. A ServletContext object will be shared by all the Servlets which are present in Web Application . Every Servlet of a Web Application contain individually a Servlet Configuration object.
  3. A ServletContext defines a set of methods that a Servlet uses to communicate with its Servlet Container . The ServletConfig is to pass configuration information to a Servlet . The Server passes an object that implements the ServletConfig interface to the Servlet's init() method
  4. ServletContext object is used to access the Context parameters specified in web.xml file. A Servlet Config object is used to access the Initialization parameters specified for particular Servlet in a web.xml file.
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: