aspose file tools*
The moose likes JSP and the fly likes problem while logging out from application. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "problem while logging out from application." Watch "problem while logging out from application." New topic
Author

problem while logging out from application.

Omkar G. Deshmukh
Ranch Hand

Joined: Sep 21, 2012
Posts: 41
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--
}
}
}
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
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


Programming is about thinking, NOT coding
 
 
subject: problem while logging out from application.