can anybody pls let me know the difference between the methods:
1.getServletContext()
2.getServletConfig().getServletContext()
How does the ServletContext returned by these two methods differ?
There is no any difference!
Acctually, they are the same method.
Please note that the GenericServlet implements the ServletConfig interface as well as
Servlet interface. And all HttpServlets are children of GenericServlet.
getServletContext() is defined in ServletConfig interface and is implemented in GenericServlet.
So you can use either the getServletContext() of HttpServlet or use the getServletContext() of the ServletConfig.
They are absolutely the same!