Howdy,

>as a context init parameter). The idea is to refuse to run unless the
>server and database versions match. This part is easy. The problem is
that
>I can't return an error condition since contextInitialized() returns
void,
>and I can't throw a checked exception because the interface isn't
declared
>to do so ... am I missing something? How can I shut down, presumably
with
>some sensible message to the log file, on such a mismatch?

Logging is easy: you can log to the servlet context's log using:
ServletContext sc = sce.getServletContext();
sc.log(getClass().getName() + "contextInitialized(): database schema
mismatch, quitting.");

For the "refuse to run" part, you can do several things:

- Call System.exit(1) to bring down the server ;) ;)  This is obviously
not friendly to other apps on the server and generally not graceful.

- Have some flag in a singleton object that says the app should refuse
to run, and have a filter (mapped to /*) check this singleton flag for
every request, and refuse to let requests proceed if the flag is set.
(Or the filter can redirect to a custom error page, or whatever).

I like the 2nd solution above so I'm going to stop here, even though
there are other approaches.

Yoav Shapira



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]

Reply via email to