Thor
Thor

Reputation: 10068

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

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.

Upvotes: 3

Views: 1915

Answers (1)

Oleg
Oleg

Reputation: 6324

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

Upvotes: 6

Related Questions