Difference between ServletConfig and ServletContext

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.
What is the difference between doGet() and doPost()?
In doGet(), the parameters are appended to the URL and sent along with header information...
Difference between using getSession(true) and getSession(false) methods
getSession(true) will check whether a session already exists for the user. If yes, it will return that session object else it will create a new session...
Difference between a JavaBean from a Servlet
Servlet and JavaBean - Servlets are Java based analog to CGI programs, implemented by means of a servlet container associated with an HTTP server...
Post your comment