Solved

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

Posted on 2004-09-07
14
193 Views
Last Modified: 2010-03-31
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
Comment
Question by:sdushyanth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
14 Comments
 

Author Comment

by:sdushyanth
ID: 11996204
please send me solution to this question,
thank u
dushyanth
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 11996211
Try moving these lines above the <html> tag

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

 
%>
0
 
LVL 12

Expert Comment

by:Giant2
ID: 11996217
the browser back button is not governed by your code.
Yu could disable this button, so you don't care about this.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:Giant2
ID: 11996233
0
 

Author Comment

by:sdushyanth
ID: 11997138
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
 

Author Comment

by:sdushyanth
ID: 11997871
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
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12001379
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 12003780
sdushyanth,

try using addHeader() instead of setHeader()
0
 
LVL 1

Expert Comment

by:jLasitha
ID: 12004223
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
 
LVL 12

Expert Comment

by:Giant2
ID: 12200679
I think a delete with point not refund because some solution were done, but sdushyanth not accept any of them(for now).
0
 
LVL 92

Expert Comment

by:objects
ID: 12204570
the code in the link I posted fixed the same problem in that question.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question