which event occur first Servlet mapping or Servlet class loading?
i think Servlet mapping occur first then servlet class loading occur
please tell me i am correct or not?
It will show you the order that elements need to appear in the deployment descriptor (web.xml)
The web.xml (in Tomcat anyway) is parsed using a SAX parser which means that the events are fired in the order in which they appear in the xml file.
The servlet elements appear before the mappings.
I've also seen mappings fail if they can't find the servlet to which the refer. This would tell me that the servlet needs to be loaded before a mapping to it can exist.
The servlet container is responsible for loading and instantiating servlets. The loading and instantiation can occur when the container is started, or delayed until the container determines the servlet is needed to service a request. When the servlet engine is started, needed servlet classes must be located by the servlet container.
From this I infer that, when the servlet engine starts it "locates" all the servlet classes via <servlet> element from web.xml file.
But the "loading" of the servlet class, entirely depends on the container's implementation. If the container is implemented to load all the servlet class when it is started, then the loading would precede the mapping. If the container is implemented to load the servlet class, only when it is needed to service a request, then mapping would precede the loading.