Brian Burridge wrote:

> What would destroy the application object?
>
> Brian N. Burridge
> Lead Internet Analyst
> Cox Target Media
>

That's a pretty interesting question, actually.

The 2.1 servlet specification does not say much, other than that a servlet
context "defines the servlet's view of the servlet engine."  In the reference
implementation, and in other servlet engines I am familiar with, the lifetime
of the servlet context is from when the servlet engine is started until when
it stops.  You can, of course, remove an application-scoped object at any time
yourself, by using the ServletContext.removeAttribute() method.

The 1.0 JSP spec says that "All references to the object [stored with
application scope] shall be released when the runtime environment reclaims the
ServletContext.  Presumably, this only happens when the servlet engine shuts
down.

Note that there is no mechanism for your object to know when it is added to,
or removed from, the servlet context.  This is a hole in the current servlet
API, and I would expect to see something similar to HttpSessionBindingListener
added for objects that are being bound and unbound from the servlet context
(i.e. application scope) and from the request (i.e. request scope) in some
future version of the servlet API.

Example:  let's say you used this approach to share a JDBC connection pool
object for your beans and servlets.  There is no way for the servlet engine to
tell the connection pool to shut down gracefully, so you'll need to manage
that by some application specific means in the mean time.

Craig McClanahan


Gabriel Wong wrote:

>
> > Brian Burridge wrote:
> > >
> > > Has anyone used the "application" lifespan? Am I correct in assuming
> > > that this functions similiar to a servlet, in that if I use
> > > "applicaiton" lifespan, the bean and its contents (objects) are
> > > accessible to that application, even across user sessions, until the
> > > server unloads the servlet, probably through shutdown/restart?
> > >
> > > I haven't used this lifespan before, but need to use a global object
> > > across sessions. I am using spec .92.
> > Yes to the above but note unloading a servlet does not mean the
> > application object is destroyed.
> >
> > Gabriel Wong
> > http://www.ezwebtools.com
> > -------------------------
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JSP-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to