List out the difference between ServletConfig and ServletContext?- Both are interfaces in the package javax.servlet.
- ServletConfig is a servlet configuration object.
- It is used by a servlet container to pass information to a servlet during initialization.
- The ServletConfig parameters are specified for a particular servlet and are unknown to other servlets.
- The ServletContext object is contained within the ServletConfig object.
- It is provided by the web server to the servlet when the servlet is initialized.
- ServletContext is an interface which has a set of methods like getServletName(), getServletContext(), getInitParameter(), getInitParameterNames().
- The servlet uses to interact with its servlet container.
- ServletContext is common to all servlets within the same web application. So, servlets use ServletContext to share context information.
|