Hi, in fact, servlet filters are classes that realize the ServletFilter interface. They have access to same data than servlets, but have a different lifecycle. They can be declared in the web.xml (as servlets) but before or after a servlet call.
In my mind, you create a servlet filter that test for a specific context value (boolean willSoonShutdown). If false, just do nothing, and the following servlet do his usual task. If true, redirect the request to a specific HTML page (<H1>Hello, the server will be down in few minutes, please deconnect</H1>). Next , declare this filter in your web.xml before EVERY servlet. Nevertheless, you need to have a way to correctly switch the "willSooonShutdown" value. Maybe by a specific administrator interface (using servlet in the same application context). Or other way. I think you can do more than this with servlet 2.3 and ( ServletContextListener or ServletContextAttributeListener ). I'am not experienced enough with the last one to tell more. The only problem, is then that you are stoping the application by intercepting all the request. I think you can do best, by coding a smarter ServletFilter, wich test if a specific user has ever been noticed of the server shutdown, and if so, do not redirect the request and let the user finish his job with the application. Here are some good (in my mind) pointers : Filter code with Servlet 2.3 model : http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters_p.html Servlet App Event Listeners : http://www.onjava.com/lpt/a/767 Servlet 2.3: New features exposed (old but good) http://www.javaworld.com/javaworld/jw-01-2001/jw-0126-servletapi_p.html Hope this is more clear (except my awful inaglish !!). Regards, Cédric ----- Original Message ----- From: "Murthy, Suryanarayana (MED, TCS)" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 21, 2002 1:33 PM Subject: Re: How to broadcast a message > Hi Cedric, > Could you please elaborate your point? I did not understand clearly. I mean, > how the server administrator can send the message to all the connected users > using Servletfilter? Though my question may be silly, but I would like to > know the procedure to do that using Filter. > > > Murthy > > -----Original Message----- > From: Cédric Viaud [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 21, 2002 11:31 AM > To: [EMAIL PROTECTED] > Subject: Re: How to broadcast a message > > Or maybe, but it is an early idea (my brain is yet sleeping), you could use > a servletFilter if you use Servlet 2.3. > > So your front filter will redirect users to an HTML page whith your message > before processing requests. The filter could do it or not depending on value > in the application context. > > The servletFilter way avoid to modify all your JSPs. You just have to modify > your web.xml to indicate servlet filtering for all yours Servlet/JSP. > > Hope this help, > > regards, > > Cédric > > ----- Original Message ----- > From: "Richard Yee" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, August 21, 2002 6:05 AM > Subject: Re: How to broadcast a message > > > > You could have all of your JSP's check for the presence of an application > > variable. If the variable is found, a JavaScript popup window can be made > > to appear the next time the server sends a response and the appropriate > > message can be displayed. Note that the message will only appear once a > > client makes a request to the server. If a client doesn't send a request > to > > the server between the time that you decide to send the message and the > > time you shut the server down, they won't get a notification. There are > > other things you could possibly do such as run applets on the client's > > browser and have the server send messages to the applets, but I personally > > don't think it is worth the trouble and added overhead. > > > > Regards, > > > > Richard > > > > At 10:41 AM 8/21/2002 +0800, you wrote: > > >Hi all, > > > > > >I have an application running on Tomcat. If I want to shutdown for > > >maintenance. How do I broadcast a message to all the on-line user ? > > >Kindly provide any pointer if possible. > > > > > >Thanks. > > > > > >Regards, > > >KL > > > > > > >___________________________________________________________________________ > > >To unsubscribe, send email to [EMAIL PROTECTED] and include in the > body > > >of the message "signoff SERVLET-INTEREST". > > > > > >Archives: http://archives.java.sun.com/archives/servlet-interest.html > > >Resources: http://java.sun.com/products/servlet/external-resources.html > > >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > > > > ___________________________________________________________________________ > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the > body > > of the message "signoff SERVLET-INTEREST". > > > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > > Resources: http://java.sun.com/products/servlet/external-resources.html > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > > > ___________________________________________________________________________ > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > ___________________________________________________________________________ > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html