• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diffrence betweeen Listener and <load on Start Up>

 
ankit kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • 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 ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
kashif bashir
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
ya i got .

Thanks Christophe and kashif
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic