How does the Tomcat container create servlet class instances?

Alibaba cloud Q & A 2022-02-13 06:13:02 阅读数:715

tomcat container create servlet class

tomcat How containers are created servlet Class instance ?

Take the answer 1:

When the container starts , Will read in webapps All the web In application web.xml file , Then on xml File parsing , And read servlet Registration information . then , Register... In each app servlet Classes are loaded , And pass Instantiate the way of reflection .( Sometimes it's also instantiated on the first request )

stay servlet Sign up with 1 If it's a positive number , Instantiate at the beginning , If it's not written or negative , The first request for instantiation .

copyright:author[Alibaba cloud Q & A],Please bring the original link to reprint, thank you.