Hi,
I 've created a website on Online Hotel Management System, everything is working fine till now in the project but one.
I have this logIn.java file...
and this logOut.java file..package fiveStar; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.*; import javax.servlet.http.*; /** * * @author RITU */ public class logIn extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String type=request.getParameter("logAs"); String id=request.getParameter("logId"); String p=request.getParameter("pwd"); try { Context c = new InitialContext(); loginLocal l = (loginLocal) c.lookup("java:global/OnlineHotelManagement/OnlineHotelManagement-ejb/login!pack.loginLocal"); if(l.logMe(id, p)){ if(type.equals("Administrator")){ RequestDispatcher rd=request.getRequestDispatcher("Admnstr.jsp"); request.getSession(true); session.setAttribute("user", type); session.setAttribute("url","Admnstr.jsp" ); rd.forward(request, response); } else if(type.equals("booker")){ RequestDispatcher rd=request.getRequestDispatcher("Booking.jsp"); request.getSession(true); session.setAttribute("user", type); session.setAttribute("url","Booking.jsp" ); rd.forward(request, response); } else{ RequestDispatcher rd=request.getRequestDispatcher("Error.html"); rd.forward(request, response); } } } catch (NamingException ne) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne); throw new RuntimeException(ne); } } }
package fiveStar; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.*; import javax.servlet.http.*; /** * * @author RITU */ public class logOut extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { HttpSession session= request.getSession(false); if(session!=null){ session.removeAttribute("user"); session.removeAttribute("eml"); session.removeAttribute("url"); session.invalidate(); } response.sendRedirect("index.jsp"); } finally { out.close(); } } }
both the files are working, that means i can log in, enter the user page, and after logging out i get redirected to index.jsp. upto this everything is working.
But, then when i am clicking on the Back button on the browser, i get back to the previous page, from where i'd been logged out.
how can i stop the browser to get back to the previous page?
I mean, once logged out, the user should by no means go back to her page without re-logging, not even by clicking on the back button of the browser.
Isn't that possible?
If no, then why is it not possible? if it's possible, how can i make this happen for my code?
thanks in advance..