[TL;DR at the end]
We are upgrading some components which are old jsp based to rest end-point based, tricky part is we have to keep the end-user behavior as it is. I