0

I just have created a Java Filter that, if one of its properties has a true value, the filter will redirect all the requests to a maintenance JSP (the server is not operational). If that property has a false value, the filter will redirect to the right target. The filter reads the boolean value from a config.properties file. It's something like this:

// Read the file property
private static boolean MAINTENANCE = Boolean.parseBoolean(p.getProperty("maintenance"));
...

if(MAINTENANCE) {
   redirectToURL("maintenance.jsp"); // maintenance JSP
}
else {
   chain.doFilter(request, response); // requested jsp/servlet
}
...

The point is... If my Web is running and I want to put it in maintenance mode, how could I do to make the server reads the new value of that property from the file?

I mean: I connect to the server, edit the config file, set "maintenance" property to value equal to true... But, how can I do to make the web application read it?

Thanks!

4
  • 1
    Which application server are you planning on using? Have you tried taking a look at these answers: update properties file run time, change properties file run time and Update properties file at runtime. Commented Aug 23, 2017 at 14:37
  • I'm using Tomcat with Java 8 Commented Aug 23, 2017 at 14:38
  • 1
    Then take a look at this answer. Furthermore, you should think about creating a way of modifying your config file through your application. That way you could trigger its reload and replace the values loaded on the container's initialization. Commented Aug 23, 2017 at 14:42
  • Thank you, @aribeiro. One of your links gave me the idea :) Commented Aug 23, 2017 at 14:49

1 Answer 1

0

Thanks to @aribeiro, I achieved the solution for me.

For the WebApp startup, I would read the properties from the file.

When I want to make a change of some attribute, I would have to use a request that changes explicitly the value (maybe from an own admin panel).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.