Suppose that user has opened 2 different pages of my application in two different tabs. If the user logs out from the first tab and performs some action on another tab then he must be redirected to index.jsp (login page). This is what should happen ideally. But in my case in the second tab NullPointerException is thrown because session is null as user has logged out from the first tab. In order to avoid this problem, I added a check in pageLoad method of my controller
HttpSession session = pRequest.getSession(false);
if (session == null) {
Map lDataMap = new HashMap();
return new ModelAndView("index", lDataMap);
}
But I cant return ModelAndView object from all of my controller methods. Because few methods are there in my controller which are being called from JavaScript using DWR. They are returning boolean. I cant change their return type.
I need a different solution to avoid this problem. Main problem is want to stop the user from entering the application after he has logged out until he logs in again.