soumyaansh roy wrote:what are the significance of ServletContext and ServletConfig what kind of information we save in these 2 objects please give some practical examples , thanks
wea sels wrote:Yes but what I would like to understand is ServletContext and ServletConfig are interfaces so how are config and context passed as objects??
http://www.java2s.com/Tutorial/Java/0400__Servlet/GetServletContextInitParameter.htm
wea sels wrote:Hi,
my question is ServletConfig and ServletContext are interfaces implemented by GenericServlet and HttpServlet classes so how can they have objects?
Like
ServletConfig config;
ServletContext context;
[Answer1] config/ context are the objects and are type casted to ServletConfig/ ServletContext which java permits
if they are interface references how can they be passed as objects
example : super.init(config);
[Answer2] Answers1 states that config/ context are the objects so perfectly legal to pass the objects
also if we use the above overriding statement
why is the following statement correct?
super.init(config);
ServletContext context=getServletContext();
what does it mean:: The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.
I have gone through the docs but couldnt understand so i am posting here. Thanks