Tomcat Manager web app allows me to easily restart a web app.
So,when I got the exception like Java heap memory problem, I wanted to restart the context(or call the manager URL) programmatically.
In between any request comes to server(context) will hold up to the completion of the context restart then after process that request.
Can you guide me how to achieve the above scenario.
I think the "Out of memory error" is not meant to be caught neither the JVM will be running after this error occurs. Tomcat and JVM both will be going down. So there is no way to reload the context, to be specific store the context for later reload.
If you want to queue requests when the application is down, then my guess is you need another load balancing server or a queuing server simply because the current server is not able to bear with the load its working with.