Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

 


Write code on Logout Servlet


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

HttpSession ses = request.getSession();

ses.removeAttribute("sessionuid");

ses.invalidate();

response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.

response.setHeader("Pragma", "no-cache"); // HTTP 1.0.

response.setDateHeader("Expires", 0); // Proxies.

//response.sendRedirect("home.jsp");

response.sendRedirect("student/userlogin.jsp");

}




and write code on login.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<SCRIPT type="text/javascript">
window.history.forward();
function noBack() { window.history.forward(); }
</SCRIPT>
<%

response.setHeader("Cache-Control","no-cache");
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
    if(session.getAttribute("token")==null){
    //response.sendRedirect(request.getContextPath() + "/LogOut.jsp");

}
%>
</head>
<body onload="noBack();" 
onpageshow="if (event.persisted) noBack();" onunload="">


</body>




Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post