• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Diffrence betweeen Listener and <load on Start Up>

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

I want to know the exact diffrence b/w listener nad <load on start up tag>
listener will be the first when we start the application and should execute first
<load on start up > tag do the same thing it load the servlet at the time of deployment

In HFSJ one example is given on page 171 . can i do the same thing with the <load on start up > tag ?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, the correct spelling is "load-on-startup". If you don't remember how tags are spelt, you might get surprises at the exam.

About your problem, listeners are loaded at deployment time, so they don't need a load-on-startup. Servlets, unlike listeners, are not loaded at deployment time, but the first time they are accessed. If you want to force a servlet to be initialized at deployment time, you can set "load-on-startup" for the servlet.

(I don't have HFSJ so I can't say about page 171)
 
ankit kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Servlets, unlike listeners, are not loaded at deployment time, but the first time they are accessed.




sorry for asking again I am not clear about it can you explain it in detail
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the application is deployed, servlets are not loaded, not initialized. Imagine that you have some initialization stuff in a servlet's init() method, and that you want it to be initialized at startup, then you will need to tell the container to load your servlet immediately. You can use the "load-on-startup" tag to do so.

Try to make a servlet and to do something in the init method. Check what happens at startup, with and without "load-on-startup" set.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kumar

Christophe is rite,
Servlets executes on concept of Lazy Loading, it means they will load in memory when they called otherwise not, if some one like you wana call servlet (eager loaded) while on application start up, then you have to specify it in <load-on-startup>. listeners are eager loaded with application.

Kashif Bashir
kashefbasher@gmail.com
 
ankit kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya i got .

Thanks Christophe and kashif
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic