Hello!!! I have a very basic doubt about loading of servlets.When does a sevlet get loaded exactly?Is it loaded when the web server starts up or is it loaded when the server receives the first request for a specific servlet.Is there any way of controlling the exact timing of loading various servlets Also ..if i want to load a certain servlet at startup how can i do that.I am using TOMCAT as my servlet engine. TIA Cheers Jayram
Hi Jayram, Here let me clarify one thing. Whenever a webserver receives a request from the client, and if it found it as a servlet, it redirects the request to the servlet container, the servlet container inturn sends the request to the appropriate servlet. So, the servlet gets loaded in the jvm the first times it gets request and remains there for some time, so whenever the next request comes it is readily available to serve it. Yes, you can load a servlet as soon as u start webserver. I dont know how to do it in tomcat, but here are the steps, how you can do in java webserver 2.0. 1) type http://localhost:9090 at your browser address bar. 2) type user name and password. 3) select webservice. 4) select servlets tab. 5) select the servlet u wish to start as soon as webserver starts 6) In the configuration panel select load at start up option. Hope this info may be useful to you. Loke [This message has been edited by lokesh reddy (edited October 30, 2000).]
Hai Jayram! A servlet gets loaded when the server first receives request for the servlet.There is no way to control the exact time to load various servlets. I know how to load a servlet at startup in Javawebserver2.0 I don't have knowledge regd Tomcat. Thanks preethi
The Servlet 2.2 spec specifies a "load-on-startup" tag in the deployment descriptor. If no load-on-startup is specified for a servlet, it is loaded when the servlet container feels like it, which is usually on the first request. If the servlet directive contains a load-on-startup it may optionally have an associated integer, indicating the position in the sequence of servlets to be started when the container starts. Example 1: A servlet which is loaded on startup
Example 1: Two servlets, both loaded on startup, but "exampleFirst" is loaded first, and "exampleSecond" is loaded second.