checking one servlet status from another servlet

北战南征 提交于 2020-01-15 14:30:50

问题


My application consists of 2 servlets,the major one loads the config files in init method and processes get/post requests, if anything fails during config load, i need to stop the application.

as far i know, i couldnt be able to stop whole application context through some java code ,hence i'm throwing UnavailableException in Servlet.hence i wont be processing get/post request.

but the second servlet does some dynamic reload of configuration on demand.but irrespective of major servlet failed or succeed,it processes reloading requests.

can you suggest a way to check the status of major servlet (running,stopped).so that second servlet can take decision whether to accept reload request or not.


回答1:


Just share some status variable, like AtomicBoolean between two servlets. By the way, it's more clear design to make both servlets just accept http requests, decode them and pass requests to corresponding business-logic objects. This way, servlets will contain only logic concerned with HTTP sending/receiving.



来源:https://stackoverflow.com/questions/6609556/checking-one-servlet-status-from-another-servlet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!