File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<load-on-startup> Confusion?

 
Prash Singh
Ranch Hand
Posts: 103
jQuery Netbeans IDE Notepad
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

There is an element of web.xml.
<load-on-startup>

What is the purpose of this element.?

I checked many forums but there is something which i couldn't understand.

why is this element always set to 1???
like:
<load-on-startup>1</load-on-startup>

Is this because this is the smallest positive integer?

Please clarify my doubts.

Thanks in advance.

 
Nicola Garofalo
Ranch Hand
Posts: 308
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That tag tells the server to create an instance of your servlet when it starts up.

The integer number indicates the load order if there are other servlet you want to be loaded on start up.

The lower is the number, the sooner (among other servlets) the servlet is loaded.

If you don't specify a positive integer value the servlet could be loaded at any time during startup.
 
Prash Singh
Ranch Hand
Posts: 103
jQuery Netbeans IDE Notepad
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Nicola Garofalo,

Thanks for your prompt reply.

But if i don't specify the number , will it make any difference?
If I write 10 instead of 1, what will be the effect?

Thanks in Advance.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
 
xsunil kumar
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prash, numbers inside load on startup tag means :- Let suppost that you have 3 servelts and that you want to start at the starting of the server itself. You have one more req. that servlet A should start first, then Servlet B, then servlet C.

This you can do it by using load on startup tag and numeric value inside it.

For example

For Servlet A

<load-on-startup>1</load-on-startup>
For Servlet B:-
<load-on-startup>2</load-on-startup>
For Servlet C:-
<load-on-startup>1</load-on-startup>

In this way you are telling to server that i want to load these servelts in above order.

-Sunil
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
xsunil kumar wrote:that servlet A should start first, then Servlet B, then servlet C.
For Servlet A

<load-on-startup>1</load-on-startup>
For Servlet B:-
<load-on-startup>2</load-on-startup>
For Servlet C:-
<load-on-startup>1</load-on-startup>


the order would be A , C and then B . the value indicates priority
 
xsunil kumar
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Less value more priority.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic