Question

Like all CMS systems like wordpress, Drupal has maintenance mode where user see custom message indicating site is been offline for maintenance. How can I do that in my web application made using struts?

My ideas:

1) Design separate web application with same context path and live it during maintenance and offline your original site. That second app only contains maintenance page and for page not found too it displays maintenance page.

2) Putting maintenance mode value in properties file or some xml file or database value and on every action call checking it, if it's true then redirecting to maintenance mode page. (Better than first one but there are many actions already made, will consume lot of time to insert condition code in each of them, specially in dispatch action files, but this will be permanent inbuilt app solution.)

What I am looking for?

Creating some sort of global action, which redirects every action path to maintenance page.

something like this:

<action-mappings>
 <action path="/*" forward="/jsp/maintenance.jsp"/>
</action-mappings>

Any ideas would be greatly helpful.

Thanks.

Was it helpful?

Solution

To block user during maintenance mode you need to switch a user from normal mode to maintenance mode. A way to intercept all incoming requests and redirect them to the maintenance mode page, is to add a Servlet Filter to your web application. Inside the Servlet Filter you need to check whether the filter is in normal operation mode, or maintenance mode.

If the filter is in normal operation mode, the request is passed on to the web application as normal. If the filter is in maintenance mode the request should be passed on to a maintenance message page instead.

The following link can help you in configuring filter in maintenance mode :

http://tutorials.jenkov.com/java-web-apps/web-app-maintenance.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top