Re: ServletContextListener: how to suspend web app on error

2004-01-09 Thread Tim Funk
A simple generic way is to use a filter which executes on all requests.

If the ServletContextListener has an error - it can set a variable in the 
application context.

Then the filter can check for the existence of that variables. Then forward 
to an error page.

For example ...
doFilter( ... ) {
   if (null!=servletContext.getAttribute(startupError)) {
   servletContext.getRequestDispatcher(/WEB-INF/error.jsp)
  .forward(request, response);
   } else {
   chain.doFilter(...);
   }
}
-Tim

Justin Ruthenbeck wrote:
Seems like a simple question, can't seem to find the answer...

If an error occurs in the #contextInitialized() method of an object that 
implements ServletContextListener, how can I suspend the web application 
so that it is unavailable for use by clients?

Specifically, I have a ServletContextListener that needs to be run at 
application startup.  If any one of many errors occur, I want to notify 
the appropriate people (this I can do) and make the entire webapp 
unavailable (this I can't figure out).

Any help is appreciated.  I have a feeling this is obvious and I'm just 
missing something.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: ServletContextListener: how to suspend web app on error

2004-01-09 Thread Shapira, Yoav

Howdy,
Throw any RuntimeException from the method, and the server will mark the
context as unavailable -- all requests will return HTTP code 503.  Tim's
filter approach is fine too.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Justin Ruthenbeck [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 08, 2004 7:36 PM
To: Tomcat User List
Subject: ServletContextListener: how to suspend web app on error


Seems like a simple question, can't seem to find the answer...

If an error occurs in the #contextInitialized() method of an object
that
implements ServletContextListener, how can I suspend the web
application
so that it is unavailable for use by clients?

Specifically, I have a ServletContextListener that needs to be run at
application startup.  If any one of many errors occur, I want to notify
the appropriate people (this I can do) and make the entire webapp
unavailable (this I can't figure out).

Any help is appreciated.  I have a feeling this is obvious and I'm just
missing something.

Cheers,
justin



__
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential. See:
http://www.nextengine.com/confidentiality.php
__


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



ServletContextListener: how to suspend web app on error

2004-01-08 Thread Justin Ruthenbeck
Seems like a simple question, can't seem to find the answer...

If an error occurs in the #contextInitialized() method of an object that 
implements ServletContextListener, how can I suspend the web application 
so that it is unavailable for use by clients?

Specifically, I have a ServletContextListener that needs to be run at 
application startup.  If any one of many errors occur, I want to notify 
the appropriate people (this I can do) and make the entire webapp 
unavailable (this I can't figure out).

Any help is appreciated.  I have a feeling this is obvious and I'm just 
missing something.

Cheers,
justin


__
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential. See:
http://www.nextengine.com/confidentiality.php
__
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]