File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which event occur first Servlet mapping or Servlet loading

 
ganesh pol
Ranch Hand
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends can any one tell me
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?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the servlet spec. The link is in my signature.
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.
 
Ana Nava
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Servlet Spec 2.4, page 25 under the title SRV.2.3.1 Loading and Instantiation, following is stated :

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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Load" / "LOCATE"

Thats a good distinction.
There would be no point in the load-on-startup attribute otherwise.

Thanks
[ June 21, 2005: Message edited by: Ben Souther ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic