aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Diffrence betweeen Listener and <load on Start Up> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Diffrence betweeen Listener and <load on Start Up>" Watch "Diffrence betweeen Listener and <load on Start Up>" New topic
Author

Diffrence betweeen Listener and <load on Start Up>

ankit kumar
Ranch Hand

Joined: Apr 28, 2008
Posts: 108
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 ?


Cleared SCJP 1.5 | Cleared SCWCD 5.0
SCDJWS 6 in progress.....
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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)


[My Blog]
All roads lead to JavaRanch
ankit kumar
Ranch Hand

Joined: Apr 28, 2008
Posts: 108
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: May 14, 2008
Posts: 17
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

Joined: Apr 28, 2008
Posts: 108
ya i got .

Thanks Christophe and kashif
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Diffrence betweeen Listener and <load on Start Up>