I have achieved container based authentication using Tomcat 8.5 and spring. However now i am trying to achieve logout using a simple button in the jsp page which is not working. Any help is appreciated: Here are the steps I am doing: 1)Placed a button in the jsp page called logout. 2)On click of logout button calling logout.do (which is a method in the UserController). 3)Invocation of Controller methods invalidates the session and returns the user to logout.jsp. 4)Logout.jsp redirects the user to index.jsp
Initiallly when I launch the homepage I am prompted for Userid and Password, a dialog box given by Tomcat container itself. After login when I am clicking the "Logout" button in the jsp, UserController is getting invoked and the session is also getting invalidated, however when I try to open the index.page again in the browser I am able to login in directly without being prompted for the login dialog box provided by Tomcat.
The same is working fine when I am trying to achieve using FORM based login but not working when I am trying to achieve using DIGEST based login. Any help would be appreciated. Here are my code snippets:
UserController.java
@RequestMapping(value = "/logout.do",method = RequestMethod.GET)
public ModelAndView logout(HttpServletRequest request)
{
ModelAndView mav;
HttpSession session = request.getSession();
if (session != null){
session.invalidate();
}
mav = new ModelAndView("logout.jsp");
return mav;
}
logout.jsp
<%
response.sendRedirect("index.jsp");
%>
Is there anything particular for Container Based Authentication which I am missing ??
Comments
Post a Comment