I am currently writing a java web application that performs certain checks at startup. Example: checking the presence of a configuration file and determining all the necessary variables.
I placed the control code inside a subclass of the class ServletContextListenerand registered the subclass of ServletContextListener inside web.xml using:
ServletContextListener
<listener> <listener-class>com.bloxware.lls3.MainContextListener</listener-class> </listener>
In the overridden contextInitialized () method, I wrote code that validates the configuration file in place and contains valid values.
If an error occurred during startup, I want to register this error and inform the web user accordingly.
I need help on how to move on from here :
Am I reading the configuration file settings in the right place (inside the ServletContextListener.contextInitialized (..) method)?
How can I handle showing the error page to the user after that (for example, should I add code to each servlet and jsp page to check the global flag, or can I do it more intelligently, maybe ServletRequestListener.requestInitialized (..))?
I need a way that if the user corrects the configuration file, it is enough to refresh the page and there is no need to restart the web application.
I can respect the goal of having a dynamic configuration that tests itself, but really I would not suggest going this route.
( ) - , . , . , , . , . . - , , . , , - .
. , , , ( !) .
, . , -, . , , . () .
, , . , .
EDIT: . , , - , , , , . unit test .
Source: https://habr.com/ru/post/1787113/More articles:C ++ container iterators - c ++Make brackets optional in function calls - javascriptoperator implementation * in C ++ - c ++defining a caller when working with dlopen () objects - chttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1787112/determining-whether-a-window-is-in-desktop-bounds-c&usg=ALkJrhhstHzjMZYfmuVGqnt9C7tGgynkUwVC ++ 2008 compilation problems with raising - c ++Android: How to disable ScrollView vertical scrolling while scrolling HorizontalScrollView? - androidЧто я делаю неправильно при попытке развертывания с помощью инструмента миграции Force.com(ANT) - buildMercurial: exclude django settings.py after intitial commit - djangoWCF Оптимальные настройки производительности - asp.netAll Articles