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
194 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
Independent Software Vendors: 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

627 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