Create check in "mainPage.jsp" for whether "req.getAttribute("contentPage)" is null.