JAVA 1 Answer(s) 4 years and 9 months ago
Posted in : JSP-Servlet
can u please tell me the difference between ServletConfig and ServletContext object?
May 22, 2010 at 4:29 PM
1)ServletContext object is shared by all of the servlet instances within the context whereas ServletConfig object is created for every servlet instance. Or you can say ServeltContext is one for total web application , but ServeltConfig is available for each individual servlets in that application.
2)ServletConfig parameters are specified for a particular servlet and are unknown to other servlets whereas ServletContext parameters are specified for an entire application outside of any particular servlet and are available to all the servlets within that application.
3)ServletContext defines a set of methods that a servlet uses to communicate with its servlet container whereas ServletConfig is a servlet configuration object used by a servlet container used to pass information to a servlet during initialization.