引用 jsp注销登陆的代码

来源:互联网 发布:mac制作 win7安装u盘 编辑:程序博客网 时间:2024/05/17 04:12

 

引用

sunchongssjsp注销登陆的代码

login.jsp  
   
  <%@   page   contentType="text/html;   charset=GBK"   %>  
  <html>  
  <head>  
  <title>login</title>  
  </head>  
  <body   bgcolor="#ffffff">  
  <h1>管理员登录</h1>  
  <form   method="post"   action="check.jsp">  
  <br>请输入你的账号       :     <input   name="user_id"><br>  
  <br>请输入你的密码       :     <input   name="user_pass"><br>  
  <br><br>  
  <center><input   type="submit"   name="Submit"   value="登录"   >  
  <input   type="reset"   value="清除"></center>  
  <br>  
  </form>  
  </body>  
  </html>  
   
  check.jsp  
   
  <%@   page   contentType="text/html;   charset=GBK"   %>  
  <html>  
  <head>  
  <title>  
  test  
  </title>  
  </head>  
  <body   bgcolor="#ffffff">  
  <h1>  
  JBuilder   Generated   JSP  
  </h1>  
  <%  
  String     path     =     "login.jsp";  
   
  if(request.getParameter("usre_name").equals("yourname")){  
                session.setAttribute("usre_name",request.getParameter("usre_name"));  
                path   =   "success.jsp";  
  }  
  else  
  {  
              session.invalidate();  
                path   =   "login.jsp";  
  }  
  response.sendRedirect(path);  
  %>  
  </body>  
  </html>  
   
  success.jsp  
   
  <%@   page   contentType="text/html;   charset=GBK"   %>  
  <html>  
  <head>  
  <title>  
  success  
  </title>  
  </head>  
  <body   bgcolor="#ffffff">  
  <jsp:useBean   id="cardBeanId"   scope="session"   class="webapp.cardbean"   />  
  <h1>登陆成功</h1>  
  <%  
  if(session.getAttribute("usre_name")==null)  
  {  
  response.sendRedirect("errorlogin.jsp");  
  }  
  else  
  {  
  out.write("你的名字是:"+session.getAttribute("usre_name")+"<br>")  
  out.write("<a   href=   \"logout.jsp\">   注销</a><br>");  
  }%>  
  </body>  
  </html>  
   
  loout.jsp  
   
   
  <%@   page   contentType="text/html;   charset=GBK"   %>  
  <html>  
  <head>  
  <title>  
  logout  
  </title>  
  </head>  
  <body   bgcolor="#ffffff">  
  <%session.invalidate();%>  
  <h2>你已经退出,请</h2><a   href=   "login.jsp">   重新登录</a>  
  </body>  
  </html>  

 

 

如果是cookies的话就response.cookies(cookiesname)=""  
  session的话就session.abandon()  

 

注销登陆后,不能后退到以前的页面

Response.Write("<script language=javascript>window.location.replace('Login.aspx')</script>");


0 0
原创粉丝点击