I have created a LoginQuery Class that will check the login email and password from SQL database. It will return status as true if the parameter matches. And if status == true, I have forward user to "home.jsp" page. But the problem is that if user click back button in browser then again login page is seen. How to avoid login page after user has entered home page? I tried using session.invalidate(); but did not workout.
// set up an LoginQuery Object
LoginQuery lq = new LoginQuery();
boolean status = lq.checkLogin(userModel);
// use the status
if (status == true) {
HttpSession session=request.getSession();
session.setAttribute("username",email);
String url = "/home.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
} else {
String Error = "Please check your Email and Password";
request.setAttribute("Error", Error);
RequestDispatcher rd = request.getRequestDispatcher("welcome.jsp");
rd.include(request, response);
}