This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Okay, then, what do you mean by "create an object to a servlet"?
Joined: Apr 26, 2008
Normally the concept of Servlet is like, Only 1 Sevlet Object created per Servlet when 1st request hits the Servlet. But through load on startup we are getting on object to a Servlet at the time of starting of the Server, but if i want more than one Servlet Objects, is there any way by which i can achieve it.
Are you asking about the number of object instances that gets created from a servlet class? If so, generally only a single instance is created. It makes no difference whether it's created at startup (through load-on-startup) or at the first request - it's still only a single instance.
There can be several instances of the same servlet in a single web app context only if they are configured under different names (and possibly with different parameters and different URLs) in the web.xml file. [ July 23, 2008: Message edited by: Ulf Dittmer ]
Assuming you mean an instance of a servlet class, yes. Every different web application can have its own instance of a given servlet addressed by its own URL and managed separately by the servlet container. Just read the servlet API and this sort of thing will become clear.
As per Servlet specification only one object & multiple threads(if not implemented SingleThreadModel) get created for that servlet in web application. but if you want to create multiple objects: 1. As Ulf said you can configure that servlet with diffrent names. 2. you can keep multiple copies of same servlet in diffrent package and congigure that in web.xml 3.Write that servlet in multiple web applications(web.xml) and syncronize them. and for dispatch each request bu writing your own dispatcher so that for each request get forwards to diffrent web applictions.