logic added to index.js/login.jsp alogn with minor refactoring in servicesImpl