• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem while logging out from application.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i logins into my profile.i enters into 1st page there is one logout button. when i clicks on that i comes out from out my acc. But there is one link in 1st page when i clicks on that link i moves to 2nd page when i comes to 1st page by using browser back button and i click on to log out button of 1st page . i comes out from my acc. but when i clicks on browsers forword button i again comes into 2nd page. what is the problem.


empoperation.jsp--(1st page)

<script>
function go() {
window.location.replace("elogout.jsp",'window','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
self.close()
}
</script>

<%
String s1=request.getParameter("val1");
String s2=request.getParameter("val2");

session.setAttribute("user",s1);
session.setAttribute("id",s2);

%>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registarion</title>
<link rel="stylesheet" href="MyNewCss2.css">
</head>
<body>




<div ><font style="color:green ;float:left;font-size:20px;margin-left:20px;face:"Courier New", Courier, monospace;"><b>Welcome</font>  <span style="color:orange;font-size:20px;font-style:oblique;"><%=s1%>(<%=s2%>)</b></span><a href="javascript:go()" title="Log out" style="float:right;text-decoration:none;font-size: 20px;margin-left:20px; color: black;">Log Out    </a></div>
<center>


<div class="menu2"><br><br><br><br>
<a href="test.jsp" title="My Details" style="font-size: 40px;color:green;text-decoration:none;font-style:"Courier New", Courier, monospace;">My Profile</a><br><br><br>
<a href="empupdateform.jsp?msg1=<%=s1%>" title="Update employee" style=" font-size: 40px;color:orange;text-decoration:none;">Update My Profile</a><br><br><br>


</div>


</center>



</body>
</html>
============================================
test.jsp--(2nd page)

<script>
function go() {
window.location.replace("elogout.jsp",'window','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
self.close();

}


</script>

<%
String a=(String)session.getAttribute("id");
String s="";
String str="";
String str1="";


Connection con=null;
Statement smt=null;
PreparedStatement pst=null;
ResultSet rs=null;
ResultSet rs1=null;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:MyNewProjectDsn");

str="select * from compadd where Reg_id='"+a+"'";
pst=con.prepareStatement(str);
rs=pst.executeQuery();

if(rs.next())
{%>
<div><a href="javascript:go()" title="Log out" style="float:right;text-decoration:none;font-size: 20px;margin-left:20px; color: black;">Log Out    </a></div>

--my code html--
<% }
else
{
str1="select * from empregtbl where Reg_id='"+a+"'";
pst=con.prepareStatement(str1);
rs=pst.executeQuery();

while(rs.next())
{%><br><br>
<div><a href="empoperation.jsp" title="go back" style="float:left;text-decoration:none;font-size: 20px;margin-left:20px; color: black;">back    </a> <a href="javascript:go()" title="Log out" style="float:right;text-decoration:none;font-size: 20px;margin-left:20px; color: black;">Log Out    </a></div>
<br>
--my code--
}
}
}
 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

First of all usecodetags, that makes the code much more readable.

For your problem, you can maintain a session for the user and invalidate it on logout. Then in your second page you can check for the session variable, if it does not exists, you can redirect to another page

Vishal
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic