Initially there was a "sign out" link only on my index page, so I would just invalidate the session and send it back to index page....
But now I have a "sign out" link on the top of every page. So how could I dispatch a request back to the same page from where the "sign out" was clicked after invalidating a session?
HttpSession hs = request.getSession();
if (hs != null) {
hs.invalidate();
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
rd.forward(request, response);
}