Java Servlet Programing Laungage

Java Servlet Projects

Servlet Project 3

adplus-dvertising
Java Servlet :ServletContext and servletConfig Interface
Previous Home Next

Servlet Context:

ServletContext is an interface of servlet API, implementation of which is provided by the vendor.An object of type ServletContext is created by the server at the time of application deployment.ServletContext is a interface which helps us to communicate with the servlet container.

There is only one ServletContext for the entire web application and the components of the web application can share it.The ServetContext is created by the container when the web application is deployed and after that only the context is available to each servlet in the web application. This object has following uses:

  1. It is used by the server to provide application scope initialization parameters to the servlet.
  2. It is used by the servlet to share information in the form of attributes accross multiple request.
  3. It is used by the servlet to interact with the web server.

ServletConfig:-

For each servlet webserver creates an object of type ServletConfig.This object has following two use:-

  1. It is used by the server to provide the reference of ServletContext to the servlet.
  2. It is used by the server to provide servlet specific initialization parameters to the servlet.
Previous Home Next