1.

List Out The Difference Between Servletconfig And Servletcontext?

Answer»

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.

Both are interfaces in the package javax.servlet.



Discussion

No Comment Found