I'm new to
struts. I unable to prevent back button in struts 1.x. Here is my code.
in struts-config.xml my code
<!-- logout link-->
<action path="/logout" type="com.myapp.struts.Logout_Action">
<forward name="success" path="/index.jsp"/>
<forward name="failure" path="/index.jsp"/>
whenever user click on sign out, control goes to index page. ok. but whenever user clicks on back button it is going back to previous page. here is my session code.
// check session attribute
HttpSession mySession = request.getSession();
if (mySession.getAttribute("user_id") == null || mySession.getAttribute("user_id").equals(""))
{
//response.sendRedirect("index.jsp");
return mapping.findForward(FAILURE);
}
else
{
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0);
mySession.removeAttribute("user_id");
mySession.invalidate();
return mapping.findForward(SUCCESS);
}
whenever user refreshes the page after going back then only it is going to index page. in the above code the action class is extends Action.