Results 1 to 2 of 2

Thread: logout

  1. #1
    mehak is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default logout

    hey friends,
    I am currently working on a project..whenever i logout n then click the back button it displays all the previous information. please help!
    My code is as follows(dont consider the alignment!)

    login.jsp
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>home</title>

    <link href="copyrighrt.css" rel="stylesheet" type="text/css" />
    <link href="copyrighrt.css" rel="stylesheet" type="text/css" />
    </head>

    <body bgcolor="#333333">
    <table width="1024 pixels" border="0">
    <tr>
    <th width="18%" height="159" scope="row"><img src="border_shadow_r.jpg" width="243" height="163" /></th>
    <td width="64%"><img src="2.jpg" width="802" height="165" /></td>
    <td width="18%"><img src="border_shadow_l.jpg" width="243" height="161" /></td>
    </tr>
    <tr bgcolor="#000000">
    <th height="99" scope="row">&nbsp;</th>
    <td><table width="100%" height="55" border="0">
    <tr>
    <th scope="row"><a href="home.jsp">HOME</a></th>
    <td><p align="center"><a href="about.jsp"> ABOUT US</a></p></td>
    <td><div align="center"><a href="contact.jsp">CONTACT US</a></div></td>
    <td><div align="center"><a href="login.jsp">LOGIN</a></div></td>
    <td><div align="center"><a href="problem.jsp">PROBLEM</a></div></td>
    <td><div align="center"><a href="suggestion.jsp">SUGGESTION</a></div></td>
    </tr>
    </table></td>
    <td>&nbsp;</td>
    </tr>
    </table>

    <table width="1059" border="0">
    <tr >
    <th width="24%" scope="row">&nbsp;</th>
    <td width="76%" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tbody>
    <tr>
    <td width="669" align="left" valign="top"><div id="masterdiv"><br />
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tbody>
    <tr>
    <td height="19" align="center">*<strong><u>LOGIN</u></strong></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="15"></td>
    </tr>
    <tr>
    <td align="left" valign="top" id="pstory_bigdata"><div align="justify">

    <form id="login" name="login" method="post" action="submitlogin.jsp">
    <table width="100%" border="0">
    <tr>
    <th scope="row"><table width="40%" border="0" align="center">
    <tr>
    <th width="42%" align="left" scope="row"><div align="left">LOGIN ID</div></th>
    <td width="58%" align="left"><label for="loginid"></label>
    <input name="loginid" type="text" id="loginid" size="30" /></td>
    </tr>
    <tr>
    <th align="left" scope="row"><div align="left">PASSWORD</div></th>
    <td align="left"><label for="password"></label>
    <input name="password" type="password" id="password" size="30" /></td>
    </tr>

    </table><table width="40%" border="0" align="center">
    <tr>
    <th width="72%" scope="row"><div align="center">&nbsp;&nbsp;&nbsp;<a href="forgotpassword.jsp">Forgot Password</a></div></th>
    <td width="28%"><input type="submit" name="submit" id="submit" value="Submit" /></td>
    </tr>
    </table></th>&nbsp;</th>
    </tr>
    </table>
    </form>
    </p>
    </div></td>
    </tr>
    <tr>
    <td>*</td>
    </tr>
    </tbody>
    </table>
    </div></td>
    </tr>
    </tbody>
    </table></td>
    <td width="0%">&nbsp;</td>
    </tr>
    </table>
    <table width="1061" height="104" border="0">
    <tr>
    <th width="24%" height="100" scope="row">&nbsp;</th>
    <td width="76%" bgcolor="black"><div align="center">
    <table width="70%" border="0">
    <tr>
    <th scope="row"><a href="home.jsp">HOME</a></th>
    <td><p align="center"><a href="about.jsp"> ABOUT US</a></p></td>
    <td><div align="center"><a href="contact.jsp">CONTACT US</a></div></td>
    <td><div align="center"><a href="login.jsp">LOGIN</a></div></td>
    <td><div align="center"><a href="problem.jsp">PROBLEM</a></div></td>
    <td><div align="center"><a href="suggestion.jsp">SUGGESTION</a></div></td>
    </tr>
    </table>
    <table width="40%" border="0">
    <tr>
    <th class="copyright" scope="row">Copyright @ NTPC(INDIA) LIMITED.All right reserved.</th>
    </tr>
    </table>
    </div></td>
    <td width="0%">&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>

    2.sumitlogin.jsp

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@page import="java.sql.*" %>

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>


    <%

    String name1=request.getParameter("loginid");
    String name2=request.getParameter("password");

    if( name1.equals("mehak") && name2.equals("m123") || name1.equals("nipun") && name2.equals("n456") || name1.equals("ntpc") && name2.equals("n789"))
    {
    request.setAttribute("login",name1);
    request.setAttribute("status",true);
    RequestDispatcher disp=request.getRequestDispatcher("adminproblem.js p");
    disp.forward(request,response);
    }
    %>

    </body>
    </html>

    3.adminproblem
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@include file="connection.jsp" %>
    <%@include file="authentication.jsp" %>
    <%@page import="java.sql.*" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>contact us</title>
    <link href="copyrighrt.css" rel="stylesheet" type="text/css" />
    <link href="copyrighrt.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #masterdiv table tbody tr td div p u strong em {
    font-family: Verdana, Geneva, sans-serif;
    }
    </style>
    </head>



    <body bgcolor="#333333">
    <table width="1024 pixels" border="0">
    <tr>
    <th width="18%" height="159" scope="row"><img src="border_shadow_r.jpg" width="486" height="163" /></th>
    <td width="64%"><img src="heading_img3.jpg" width="1596" height="162" /></td>
    <td width="18%"><img src="border_shadow_l.jpg" width="486" height="161" /></td>
    </tr>
    <tr bgcolor="#000000">
    <th height="99" scope="row">&nbsp;</th>
    <td><table width="100%" height="55" border="0">
    <tr>
    <th scope="row"><a href="adminproblem.jsp">PROBLEM</a></th>
    <td><p align="center"><a href="adminsolution.jsp">SOLUTION</a></p></td>
    <td><div align="center"><a href="adminsuggestion.jsp">SUGGESTION</a></div></td>
    <td><div align="center"><a href="logout.jsp">LOGOUT</a></div></td>
    </tr>
    </table></td>
    <td>&nbsp;</td>
    </tr>
    </table>

    <table width="205%" border="0">
    <tr >
    <td width="105%" bgcolor="#FFFFFF"><table width="100%" height="100" border="1">
    <tr>
    <th width="5%" scope="row">EMPLOYEE NUMBER</th>
    <td width="5%">EMPLOYEE NAME</td>
    <td width="3%">MODULE NAME</td>
    <td width="4%">PHONE NUMBER</td>
    <td width="6%">EMAIL</td>
    <td width="8%">PROBLEM DESCRIPTION</td>
    <td width="5%">PROBLEM DATE</td>
    <td width="5%">PROBLEM ID</td>
    <td width="5%">SOLUTION</td>

    </tr>
    <% String login_name=(String)request.getAttribute("login");
    String cmd;
    System.out.println(login_name);

    if(login_name.equals("mehak"))
    {
    cmd="select * from problem where area='Hospitality'";
    }
    else if(login_name.equals("nipun"))
    {
    cmd="select * from problem where area='Gate Pass'";
    }
    else
    {
    cmd="select * from problem where area='Document Tracker'";
    }
    PreparedStatement psmt=con.prepareStatement(cmd);
    ResultSet rs=psmt.executeQuery();
    while(rs.next())
    {
    %>



    <tr>
    <th width="5%" scope="row"><%=rs.getString(1) %></th>
    <td width="5%"><%=rs.getString(2) %></td>
    <td width="3%"><%=rs.getString(4) %></td>
    <td width="4%"><%=rs.getString(5) %></td>
    <td width="4%"><%=rs.getString(6) %></td>
    <td width="6%"><%=rs.getString(7) %></td>
    <td width="8%"><%=rs.getString(8) %></td>
    <td width="5%"><%=rs.getInt(9) %></td>
    <td width="5%">
    <form id="submit" name="submit" method="post" action="adminresolve.jsp">
    <input type="submit" name="resolve" id="resolve" value="Resolve" />
    </form>
    </td>

    </tr>
    <% } %>
    </table></td>

    </tr>
    </table>

    <table width="2122" height="104" border="0">
    <tr>
    <th width="24%" height="100" scope="row">&nbsp;</th>
    <td width="76%" bgcolor="black"><div align="center">
    <table width="70%" border="0">
    <tr>
    <th scope="row"><a href="adminproblem.jsp">PROBLEM</a></th>
    <td><p align="center"><a href="adminsolution.jsp">SOLUTION</a></p></td>
    <td><div align="center"><a href="adminsuggestion.jsp">SUGGESTION</a></div></td>
    </tr>
    </table>
    <table width="40%" border="0">
    <tr>
    <th class="copyright" scope="row">Copyright @ GAIL(INDIA) LIMITED.All right reserved.</th>
    </tr>
    </table>
    </div></td>
    <td width="0%">&nbsp;</td>
    </tr>
    </table>

    </body>
    </html>

    4.authentication
    <%--
    Document : authentication
    Created on : Jul 6, 2011, 10:40:21 PM
    Author : USER
    --%>

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <% if((Boolean)request.getAttribute("status")==false)
    response.sendRedirect("login.jsp");
    %>

    </body>
    </html>

    5.logout
    <%--
    Document : logout
    Created on : Jul 6, 2011, 10:01:51 PM
    Author : USER
    --%>

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <% request.setAttribute("status",false);
    session.invalidate();
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Cache-Control", "must-revalidate");
    response.setDateHeader("Expires",0);

    RequestDispatcher disp=request.getRequestDispatcher("login.jsp");
    disp.forward(request,response);
    }

    %></body>
    </html>

    Thanks in advance!

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Use something like Firebug for Firefox to see if, on the back button, another request is sent to the server.
    If not (which is quite likely to be the case) then that page is being pulled from the client cache...in which case you need to tell the client not to cache those pages. Which as an HTML tag.

    If it is going back to the server (unlikely) then there is a bug in your security.

Similar Threads

  1. Help for logout and cookie
    By Sweety13 in forum Java Servlet
    Replies: 2
    Last Post: 01-12-2011, 06:59 AM
  2. problem in logout...
    By raj.33jsr in forum Java Servlet
    Replies: 2
    Last Post: 08-09-2010, 11:28 AM
  3. logout servlet needed
    By nakta in forum Java Servlet
    Replies: 0
    Last Post: 01-09-2010, 01:35 PM
  4. Logout problem
    By anki1234 in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 01-09-2008, 07:54 AM
  5. Sessions and logout question
    By orchid in forum Web Frameworks
    Replies: 1
    Last Post: 05-18-2007, 06:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •