index.jsp做成2中情况,一种是登陆了的,一种是没登陆的

解决方案 »

  1.   

    我是要停在当前页面!
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> 
    <jsp:useBean id="connDB" scope="page" class="beans.connDB"/> 
    <jsp:useBean id="chStr" scope="page" class="beans.chStr"/> 
    <% 
    String username=chStr.chStr(request.getParameter("username"));//此处必须进行编码转换,否则输入中文用户名时将出现乱码 
    try{ 
    ResultSet rs=connDB.executeQuery("select * from tb_Member where username='"+username+"' and freeze=0"); 
    if(rs.next()){ 
    String PWD=request.getParameter("PWD"); 
    if(PWD.equals(rs.getString("password"))){ 
    session.setAttribute("UserName",username); 
    response.sendRedirect("index.jsp");  
    }else{ 
    out.println(" <script language='javascript'>alert('您输入的用户名或密码错误,请与管理员联系!');window.location.href='index.jsp'; </script>"); 

    }else{ 
    out.println(" <script language='javascript'>alert('您输入的用户名或密码错误,或您的帐户已经被冻结,请与管理员联系!');window.location.href='index.jsp'; </script>"); 

    }catch(Exception e){ 
    out.println(" <script language='javascript'>alert('您的操作有误!');window.location.href='index.jsp'; </script>"); 

    %> 
      

  2.   

    你这个页面 首先url为多少,你里面有登录成功 跳转到 index.jsp这句话
    你把这句话改成 你的登录页面的地址就好了,这样成功后还是回到了登录页面