Is `ServletContext` interface implemented by any classes inside Tomcat server?

时间:2017-08-05 10:45:35

标签: java tomcat servlets java-ee

I'm currently learning Java EE using Tomcat 9 server, with focus on the ServletContext interface.

I want to know what classes implement ServletContext interface, so I checked the official Oracle documentation. But the official documentation does not list any classes that implement ServletContext interface. And I noticed that ServletContext interface is public, therefore I was thinking the ServletContext interface must have been implemented by some classes inside tomcat server.

Because I'm relatively new to Java EE and Tomcat, therefore I'm not sure if my assumption is correct. Also, if my assumption is indeed correct, could someone please tell me where I can find the source code that implement ServletContext interface? I would love to have a look at the source code and try to understand how it really works.

1 个答案:

答案 0 :(得分:4)

Yes, this is how it works. JavaEE is a specification so all you have is interfaces. The implementation is provided by the containers.

In tomcat it's implemented by ApplicationContext.java