Consider the following scenario. I have a servlet and I have my web.xml configured in such a way that 2 servlet names point to the same servlet. Then in that case, will 2 seperate instances of the servlet be created when I access it using the two url's that I configured??
Instantiate an instance of each servlet identified by a <servlet> element that includes a <load-on-startup> element in the order defined by the load-onstartup element values, and call each servlet instance�s init() method.
Hence i think declaring two different <servlet> tage with unique name pointing to same class will give you two instance of the servlet , erach corresponding to the one declared in servlet tag.
Theorotically I feel only one instance should be created
Consider the case where the two servlet declarations have different init parameters in the web.xml file, which get stored in fields in the servlet code. In order for the two servlets to reflect those different values, they can't be implemented by just a single instance.
Ping & DNS - updated with new look and Ping home screen widget
The point to note is that just like servlets (and after all, a JSP page is� ultimately�a servlet), each of these three methods of access establishes three separate instances of the servlet class within the web container. Multiple instances will occur like this only when the JSP page is registered in more than one way.
Joined: Aug 18, 2004
Agreed.. there could be multiple servlet instances for such a case