Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Performing checks on each request  RSS feed

 
Piradharsan Navaratnam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could look into ServletRequestListener.
 
Pravin Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter could be best suited for this.
you can use the filter to do the check.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A filter would be the way to go. Have a look at configuring filters
 
Sandeep Deb
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!