What's the purpose of load-on-startup tag in web.xml?
Manohar Karamballi
Ranch Hand
Joined: Jul 17, 2001
Posts: 227
posted
0
Hi Forum, Greetings.
I observed following behaviour in Tomcat server. Declare a simple Java class as a servlet using <servlet-name> and <servlet-class> tags of web.xml and then give value given in <servlet-name> tag as a value of <load-on-startup> tag. surprise..when server starts this class is getting Instantiated. Here is my question..What's the purpose of <load-on-startup> tag in web.xml? I understand that is to load servlets when webcontainer started. Secondly will container allow a simple class that is not extending servlet class to be declared as a servlet class? What is correct functionality according to standards? And if I want to start some simple Java class as a startup what is standard way of doing this? Expecting feedback. Cheers Manohar
Juanjo Bazan
Ranch Hand
Joined: Feb 04, 2002
Posts: 231
posted
0
The <load-on-startup> sub-element indicates the order in which each servlet has to be loaded. Lower positive values are loaded first. If the value is negative or unspecified, then the container can load the servlet at anytime during startup. And about your first question, it make no sense to declare a "non servlet" class as a servlet because it is unable to accept request, so you don't need the webcontainer to map it. [ October 04, 2002: Message edited by: Juanjo Bazan ]