日期:2014-05-18  浏览次数:20582 次

求求各位大大,这样使用了javabean就无法判断表单的用户名和密码啊。。。。
先看一下我的判断用户名密码的javabean  
package   com.jb.logon;
import   com.jb.logon.DB;
import   java.sql.*;
public   class   UserLogOn   {
private   String   username;
private   String   userpassword;
        private   ResultSet   rs;
private   DB   db=new   DB();
HttpServletResponse     response;
HttpServletRequest       request;
        public   UserLogOn(){}
public   void   setUsername(String   username){
this.username=username;

}
public   String   getUsername(){
return   this.username;
}
public   void   setUserpassword(String   userpassword){
this.userpassword=userpassword;
}
public   String   getUserpassword(){
return   this.userpassword;
}
        public   String   checkuser(){
        String   backstr= " ";
        boolean   mark=true;
        if(this.username==null||this.username.equals( " ")){
        backstr+= " <li> 请输入 <b> 用户名! </b> </li> <br> ";
        mark=false;
        }
        if(this.userpassword==null||this.userpassword.equals( " ")){
        backstr+= " <li> 请输入 <b> 密&nbsp;&nbsp;码! </b> </li> <br> ";
        mark=false;
        }
        if(mark){
        String   sql= "select   *   from   tb_logon   where   user_name= ' "+this.username+ " '   and   user_password= ' "+this.userpassword+ " ' ";
        try{
        rs=db.getRs(sql);
                if(!rs.next())
                backstr= "登录失败! <br> 输入的 <b> 用户名 </b> 或 <b> 密码 </b> 不存在! ";                      
                else
       
                backstr= "登录成功! <br> <table> <tr> <td> 用户名: </td> <td> "+this.username+ " </td> </tr> <tr> <td> 密&nbsp;&nbsp;码: </td> <td> "+this.userpassword+ " </td> </tr> </table> ";
    //response.sendRedirect( "main.jsp ");
   
                }catch(Exception   e){e.printStackTrace();}
          }
         
        db.closed();
       
                return   backstr;        
        }
}

----------------------------------------
然后获取表单数据的页面   dologon.jsp
<%@   page &