• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Performing checks on each request

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends ,

In my web application I thought to send a page saying "Under Construction. Sorry For inconvenience" to the customers who view my application while it is in construction. So I created a table with an attribute saying sys_shut. I need all my servlets to check sys_shut and tel the customer it is under construction. It should happen when the admin sets the value to sys_shut 'OFF'.

How to check this status when ever a request or servlet is invoked. Its like initial context param. But how to implement it.
[ June 04, 2007: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Piradharsan Navaratnam, this entire forum is devoted to question on servlets so a topic title of "Servlets" is not very descriptive. Please read this for more information and try to use more descriptive titles for your posts. I have expanded the title of this post for you.

With regards to your question, a servlet filter should serve your purpose beautifully.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could look into ServletRequestListener.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Filter could be best suited for this.
you can use the filter to do the check.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A filter would be the way to go. Have a look at configuring filters
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This genre of problems are easily handled by the Intercepting Filter and Front Controller J2EE design pattern. There are many frameworks which give you the ability to implement either or both. As many of the posts have mentioned earlier, Servlets give you the ability to implement intercepting filters via the Filters mechanism.

If you are using Struts, you can use a custom RequestProcessor or if you have an Action class hierarchy you can implement the check on the top of the hierarchy. Spring MVC also gives you the ability to implement intercepting filters. You can always implement a servlet filter irrespective of whether you are using a MVC framework or not.

I hope this helps.

- Sandeep
 
reply
    Bookmark Topic Watch Topic
  • New Topic