0

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.

Stolaine
  • 25
  • 4
  • It's on the [Servlet](https://javaee.github.io/javaee-spec/javadocs/javax/servlet/Servlet.html#getServletConfig--). – Nikos Paraskevopoulos May 14 '21 at 12:51
  • @NikosParaskevopoulos I want to understand why it is not in [ServletRequest](https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html). – Stolaine May 14 '21 at 14:58

0 Answers0