Michael is right.  A lot of people don't get this at first.

Similar to applets and EJBs, servlets don't have main() methods.  They aren't
meant to run outside of a larger application context/container.  They have an
API-specific set of methods that must be implemented for them to work correctly.
Some methods are optional, others are required to be overridden.

Like a Web browser calls an applet's init(), start(), stop() and destroy()
methods, a servlet container calls a servlet's init(), service() and destroy()
methods.  You can put stuff in those methods, but you can't call them.  The
container calls them at key times in the process of loading, running and
unloading applet and servlet (and EJB) classes.  This API stuff is how the "life
cycle" of these types of objects is defined and controlled in a predictable,
standard, safe way.

A servlet container only calls a servlet's destroy() method when the server
shuts down or when you reload a servlet dynamically by changing its class.  JRun
3.0 also exposes an API that allows you to ask the container to load() or
unload() other servlets, but this is a JRun specific feature and not commonly
used or needed (to my knowledge).

Scott Stirling
West Newton, MA

> -----Original Message-----
> From: Peacock, Michael [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 22, 2000 10:35 AM
> To: JRun-Talk
> Subject: RE: destroy() not getting called?
>
>
> Brian -
>
> destroy() is the flipside of init(), and is called by the servlet engine
> when the servlet is being unloaded.
>
> If you want to ensure some processing always occurs in your doGet, doPost,
> or service methods, use try - catch - finally blocks, and put the code you
> need to execute in the finally.
>
> HTH, Michael
>
>
> > -----Original Message-----
> > From: Brian J. Sayatovic [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, September 22, 2000 8:41 AM
> > To: JRun-Talk
> > Subject: destroy() not getting called?
> >
> >
> > How can I ensure that destroy() is getting called in my
> > servlets.  I made a
> > simpistic example that simply prints to System.out, but
> > 'detory' calls are
> > not showing up in the log.  Is there anything that could be
> > interferring
> > with destory begin called?
> >
> > I'm using JRun 2.3.3 on NT4-SP6 with PWS.
> >
> > --
> > Brian J. Sayatovic
> > mailto:[EMAIL PROTECTED]


------------------------------------------------------------------------------
Archives: http://www.egroups.com/group/jrun-interest/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/jrun_talk
or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the 
body.

Reply via email to