• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 626
  • Last Modified:

WSServlet and Multiple Web Services

I'm reading about WSServlets at http://forums.java.net/jive/thread.jspa?messageID=261509
And would like to ask about <load-on-startup>1</load-on-startup>, how do the numbers work?
Where or what is this number compared to?

The <load-on-startup> that I have, have duplicate numbers and the complete sequence is not there.  The numbers jump form 1 to 8 and 9, then 11.  Granted each of the web.xml files are not related.
  • 2
1 Solution
Kevin CrossChief Technology OfficerCommented:
Hello chima,

The number specified as content of this tag is the order in which the servlet should be loaded if it matters.  So you don't need to have all the numbers in sequence.  Just note that the servlet(s) with value of 1 will be loaded before servlet(s) with value of 8, 9, or 11.


Kevin CrossChief Technology OfficerCommented:
(here is a nice explanation -- http://wiki.metawerx.net/wiki/Web.xml.LoadOnStartup)

This tag specifies that the servlet should be loaded automatically when the web application is started.

The value is a single positive integer, which specifies the loading order. Servlets with lower values are loaded before servlets with higher values (ie: a servlet with a load-on-startup value of 1 or 5 is loaded before a servlet with a value of 10 or 20).

When loaded, the init() method of the servlet is called. Therefore this tag provides a good way to do the following:

    * start any daemon threads, such as a server listening on a TCP/IP port, or a background maintenance thread
    * perform initialisation of the application, such as parsing a settings file which provides data to other servlets/JSPs

If no  value is specified, the servlet will be loaded when the container decides it needs to be loaded - typically on it's first access. This is suitable for servlets that don't need to perform special initialisation.
chimaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now