jsp - where to include session.invalidate() code -
I have logout buttons in my jsp pages. When I click on it, then I should call a servlet and session.invalidate () Code or call on a jsp or this code should be included or the code must be included in each jsp page where I have a logout button.
Logout.jsp You only have one logout page. And you can have a logout button on each page of your web application. But once you click the logout button from any page, you should redirect to your logout.asp file. You can create a header and footer page. Here you can add your logout button. And you can add this page to each other jsp page, where you need logout button instead of writing logout button code on every page.
and lt;% @ page language = "Java" content type = "text / html; charset = ISO - 885 9-1 "Page Encoding =" ISO-8859-1 "%> & Lt;% session.invalidate (); Response.sendRedirect ("index.html"); & Gt%; & Lt ;! DOCTYPE HTML PUBLIC "- // W3C // DTD HTML 4.01 Transcription // N" "http://www.w3.org/TR/html4/loose.dtd"> & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = ISO-885 9-1" & gt; & Lt; Title & gt; Logout & lt; / Title & gt; & Lt;% response.addHeader ("Cash-Control", "No-Cash, No-Store, Private, Sure-Modified, Maximum-Sticky = 0, Post-Check = 0, Pre-Check = 0"); Response.addHeader ("Pagera", "No-Cash"); Response.addDateHeader ("End", 0); & Gt%; & Lt; / Head & gt; & Lt; Body & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment