sdushyanth
asked on
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.getAttrib ute("user" );%>
<%
response.setHeader("Cache- Control"," no-store") ;
response.setHeader("Pragma ","no-cach e");
response.setDateHeader ("Expires", 0);
%>
before<%=re%>
<%
session.removeAttribute("u ser");
%>
<% String re1 =(String)session.getAttrib ute("user" );%>
<%
session.invalidate();
String url = response.encodeURL("LoginS creen.jsp" );
response.sendRedirect(url) ;
%>
</from>
</body>
</html>
waiting for ur reply
dushyanth
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(
window.history
.forward(1);
</script>
<body>
<% String re =(String)session.getAttrib
<%
response.setHeader("Cache-
response.setHeader("Pragma
response.setDateHeader ("Expires", 0);
%>
before<%=re%>
<%
session.removeAttribute("u
%>
<% String re1 =(String)session.getAttrib
<%
session.invalidate();
String url = response.encodeURL("LoginS
response.sendRedirect(url)
%>
</from>
</body>
</html>
waiting for ur reply
dushyanth
Try moving these lines above the <html> tag
<%
response.setHeader("Cache- Control"," no-store") ;
response.setHeader("Pragma ","no-cach e");
response.setDateHeader ("Expires", 0);
%>
<%
response.setHeader("Cache-
response.setHeader("Pragma
response.setDateHeader ("Expires", 0);
%>
the browser back button is not governed by your code.
Yu could disable this button, so you don't care about this.
Yu could disable this button, so you don't care about this.
see here for details:
http://developer.irt.org/script/311.htm
http://developer.irt.org/script/311.htm
ASKER
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-cach e");
response.setDateHeader ("Expires", 0);
%>
but still it is not working ,
and
I have tried these lines above the <html> tag
<%
response.setHeader("Cache-
response.setHeader("Pragma
response.setDateHeader ("Expires", 0);
%>
but still it is not working ,
ASKER
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.getAttrib ute("user" );%>
<%
response.setHeader("Cache- Control"," no-store") ;
response.setHeader("Pragma ","no-cach e");
response.setDateHeader ("Expires", 0);
%>
before<%=re%>
<%
session.removeAttribute("u ser");
%>
<% String re1 =(String)session.getAttrib ute("user" );%>
<%
session.invalidate();
String url = response.encodeURL("LoginS creen.jsp" );
response.sendRedirect(url) ;
%>
</from>
</body>
</html>
waiting for ur reply
dushyanth
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(
window.history
.forward(1);
</script>
<body>
<% String re =(String)session.getAttrib
<%
response.setHeader("Cache-
response.setHeader("Pragma
response.setDateHeader ("Expires", 0);
%>
before<%=re%>
<%
session.removeAttribute("u
%>
<% String re1 =(String)session.getAttrib
<%
session.invalidate();
String url = response.encodeURL("LoginS
response.sendRedirect(url)
%>
</from>
</body>
</html>
waiting for ur reply
dushyanth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sdushyanth,
try using addHeader() instead of setHeader()
try using addHeader() instead of setHeader()
Check the session in all pages.if the seesion null redirect it to tha loggin page
<% if( session.getAttributr("user ") == null ){
response.senRedirect("Logi nScreen.js p");
}
%>
Put this in all pages as a header
<% if( session.getAttributr("user
response.senRedirect("Logi
}
%>
Put this in all pages as a header
I think a delete with point not refund because some solution were done, but sdushyanth not accept any of them(for now).
the code in the link I posted fixed the same problem in that question.
ASKER
thank u
dushyanth