象这样:
if (rs.next()) {
    response.sendRedirect("success.jsp");
} else {
    response.sendRedirect("error.jsp");
}

解决方案 »

  1.   

    我一般用javascript跳转
    <script>
    window.location="error.jsp";
    </script>
      

  2.   

    ......
    String sql = "select * from user where id='"+name+"' and password='"+password+"'";
    rs = qu.executeQuery(sql);
    String dir_file="error.jsp";
    while(rs.next)
    {
        String username = rs.getString(1); //第一列为用户名
        if(username==null)
        {
             dir_file="success.jsp";
         }
      
    }
    response.sendRedirect(dir_file);
      

  3.   

    while(rs.next)  这里有错误把next()
    如果输入错误的用户名和密码  rs是null的逻辑上错误了吧  应该
    if(rs!=null){
    response.sendRedirect("success.jsp");
    }else{
    response.sendRedirect("error.jsp");}祝你好运
      

  4.   

    To zengchangliu(程序人生) : 如果输入错误的用户名和密码 rs 不是 null的jkit(郁闷之堕落的程序员) 的方法是对的
      

  5.   

    应当先设置以下返回数据集的类型,不知道做过没有,如果没有的话,会在rs.next处处错。