Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Problem while logging out,removing the session variable but while navigating through back button previously viewed pages are showing up

Hai ya,

Probem: LOGOUT NOT WORKING PROPERLY,showing all previously viewed jsps.(pages)

I am designing a java web application ,using jsp,servlets and beans using model 2 architecture..
While trying to logout in web application ,it is going to login page, but we while navigating through back button, previously viewed pages are showing up, I have used removeAttribute method ,it is working fine,session variable is getting removed, But again while navigating through back button all the viewed pages are showing up. I dont know why they are not getting updated,i have written code the emptying the cache,can u please help me out in this.

here is my code in Logout.jsp..

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<html>
<head><title>JSP Page</title></head>
<script>
if(window.history.forward(1) != null)
                 window.history
.forward(1);
</script>
<body>
<% String re =(String)session.getAttribute("user");%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);

 
%>
before<%=re%>
<%
session.removeAttribute("user");
%>


<% String re1 =(String)session.getAttribute("user");%>
<%
 session.invalidate();
 


String url = response.encodeURL("LoginScreen.jsp");
response.sendRedirect(url);
%>
</from>
</body>
</html>

waiting for ur reply
dushyanth
0
sdushyanth
Asked:
sdushyanth
  • 3
  • 3
  • 2
  • +2
1 Solution
 
sdushyanthAuthor Commented:
please send me solution to this question,
thank u
dushyanth
0
 
Nick_72Commented:
Try moving these lines above the <html> tag

<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);

 
%>
0
 
Giant2Commented:
the browser back button is not governed by your code.
Yu could disable this button, so you don't care about this.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Giant2Commented:
0
 
sdushyanthAuthor Commented:
I dont want to disable the browser 's back button,
and

I have tried  these lines above the <html> tag

<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);

 
%>

but still it is not working ,
0
 
sdushyanthAuthor Commented:
Hai ya,

Probem: LOGOUT NOT WORKING PROPERLY,showing all previously viewed jsps.(pages)

I am designing a java web application ,using jsp,servlets and beans using model 2 architecture..
While trying to logout in web application ,it is going to login page, but we while navigating through back button, previously viewed pages are showing up, I have used removeAttribute method ,it is working fine,session variable is getting removed, But again while navigating through back button all the viewed pages are showing up. I dont know why they are not getting updated,i have written code the emptying the cache,can u please help me out in this.

here is my code in Logout.jsp..

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<html>
<head><title>JSP Page</title></head>
<script>
if(window.history.forward(1) != null)
                 window.history
.forward(1);
</script>
<body>
<% String re =(String)session.getAttribute("user");%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);

 
%>
before<%=re%>
<%
session.removeAttribute("user");
%>


<% String re1 =(String)session.getAttribute("user");%>
<%
 session.invalidate();
 


String url = response.encodeURL("LoginScreen.jsp");
response.sendRedirect(url);
%>
</from>
</body>
</html>

waiting for ur reply
dushyanth

0
 
Nick_72Commented:
sdushyanth,

try using addHeader() instead of setHeader()
0
 
jLasithaCommented:
Check the session in all pages.if the seesion null redirect it to tha loggin page
<% if( session.getAttributr("user") == null ){
      response.senRedirect("LoginScreen.jsp");
}
%>
Put this in all pages as a header
0
 
Giant2Commented:
I think a delete with point not refund because some solution were done, but sdushyanth not accept any of them(for now).
0
 
objectsCommented:
the code in the link I posted fixed the same problem in that question.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now