What is the difference between ServletContext and ServletConfig parameter?

1)The context parameter is available for all the servlets and jsp in a webapp, but config parameter is available for only one servlet.

2)The config parameters is declared inside<init-param></init-param> inside the <servlet></sevlet> tag in the web.xml but the context parameters are declared inside the<contaxt-param></context-param> inside the <web-apps></webapps> tag outside the <servlet> tag.

3)Config parameters is initialized when the seervlet is initialized but context parameters are initialized when we deploy the application.’

4)The getServletConfig() returns the ServletContext object and the getServletContext() returns the ServletContext object.

5)Config parameters are called by servletconfig.getInitParameter(String str), but context parameter as called as servletcontext.getInitParameter(String str).

No comments:

Post a Comment