• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loads on startup problem in web.xml.

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a confusion about loads on startup in web.xml, as per my knowledge, if we give the value 1 then , that servlet will execute first, and if the value is 2 then servlet will execute, after the first servlet, as here,

this is my web.xml:




this is my first.java




this is my second.java







so here second servlet's value is 2 in loads on startup in web.xml, if I try to execute second servlet, then it printed, mates, so I can not understand , it should print hello mates because first servlet's value is 1, so first servlet should print first, and also, I can not feel the less timing, means loads on startup consumes less time, please clearify this.
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet load order has no bearing on servlet execution. In particular, invoking one servlet will not cause another to be invoked as well. How did you get that idea?

As to seeing a difference in performance, I would not expect any given the simplicity of both classes. You might see a difference if a servlet has lengthy initialization code to run, but not here.
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok fine, but I used "load on startup" two times in each (both) servlet individually, so I can not see the effect that which servlet should execute first, it executes normally, (when I execute first, it run and when I execute second , it run), so why google says me, that if we give positive value, it starts executing in accending order, I can not see a single difference even...
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again: load order had nothing to do with execution. The servlet code is executed when it is invoked, regardless of when its class was loaded.

Maybe you can post the link to what you read, and we can either point out where that is incorrect, or where you may have misunderstood it.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Add the above method into each servlet, putting a suitable message in so you can identify them.

This is the method that gets called when the servlet is initialised.
The load-on-startup simply tells the engine to load the marked servlet(s) when the server starts up. Ones that are not marked load-on-startup will not get loaded until the first request is sent to them.
 
reply
    Bookmark Topic Watch Topic
  • New Topic