Difference between ServletsContext and ServletConfig

Difference between ServletsContext and ServletConfig

ServletConfig:
It defines how a servlet is configured. ServletConfig is implemented by the servlet container to initialize a single servlet using init (). Every servlet has its own ServletConfig object. Most servlet containers provide a way to configure a servlet at run-time and set up its initial parameters.
Example:
<servlet>
<servlet-name> abc </servlet-name>
<servlet-class> first </servlet-class>
<init-param>
<param-name> rno </param-name>
<param-value>10</param-value>
</init-param>
</servlet>
ServletContext:
ServletContext is implemented by the servlet container for all servlet to communicate with its servlet container. It is applicable only within a single Java Virtual Machine.

The ServletContext object is contained within the ServletConfig object. That is, the ServletContext can be accessed using the ServletConfig object within a servlet. You can specify param-value pairs for ServletContext object in tags in web.xml file. ServletContext is created at the application level and shared by all the Servlet codes.
<context-param>
<param-name> Name </param-name>
<param-value> Ram </param-value>
</context-param>
Why is HTTP protocol called as a stateless protocol?
HTTP is called a stateless protocol because in this each command is executed independently, without any knowledge of the commands...
Relation between class and object
Class and object - A class defines the properties and behavior for the objects represented by the abstraction. Abstraction is a property of object oriented programming...
Difference between throw and throws clause
Throw and throws clause - A program can throw an exception, using throw statement. When an exception is thrown, normal execution is suspended...
Post your comment