Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the purpose of load-on-startup tag in web.xml?

 
Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic