I am new to Java Servlets and while going through one tutorial I found this.
ServletContext context = getServletContext();
When I tried using the request object to get the ServletContext object it also worked.
ServletContext context = request.getServletContext();
But I could not find a method in the HttpServletRequest class to get ServletConfig.
ServletConfig config = request.getServletConfig();
This is not correct as HttpServletRequest
class does not have getServletCofig()
method.
Why is it so? I know that ServletConfig is acts as a local to a servlet while ServletContext acts as a global to all the servlets in the application. Is it related to this any how?
Thank you for your help.