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

jsp里使用bean出错误!
用户注册功能,想在jsp里调用bean。bean的作用是查找现在数据库里是否有相同的用户名,如果有返回1,如果没有返回0,并且把记录加到数据库里。
运行结果提示如下错误信息:
D:\Program   Files\eclipsenew\eripnew\work\org\apache\jsp\regcheck_jsp.java:48:   cannot   resolve   symbol
symbol     :   class   insertuserinfo  
location:   class   org.apache.jsp.regcheck_jsp
            insertuserinfo   insertinfo   =   null;


<jsp:useBean   id= "insertinfo "   scope= "session "   class= "insertuserinfo "   />
......
int   ifsame=0;
ifsame=insertinfo.searchinfo(loginname);
if(ifsame==1)
      out.printin( "该用户名已经存在,请更换用户名! ");
else     //   调用类方法插入数据      
      insertinfo.insertinfo(loginname,password,username,email,institute,phone,gender);

*********下面是类里的内容***************

import   java.sql.*;
import   java.sql.Statement;

public   class   insertuserinfo   {
String   loginname;
String   username;
String   passwd;
String   email;
String   phone;
String   institute;
String   gender;
String   sql;
Connection   conn;
Statement   stmt;
ResultSet   rs;

public   int   searchinfo(String   loginname)
{
    try{
            this.loginname=loginname;    
              Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
              String     url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=erip ";
              String   user= "dataprovider ";
              String   password= "123456 ";
              conn=DriverManager.getConnection(url,user,password);
              stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
              sql= "select   loginname   from   sys_userinfo   where   loginname= ' "   +   this.loginname   + " ' ";
              rs=stmt.executeQuery(sql);
              int   recordcount=0;
              recordcount=rs.getRow();
              if(recordcount==0)
          return   0;
              else
          return   1;          
            }
            catch(Exception   e){};  
             
        }
       
public   void   insertinfo(String   loginname,String   password,String   username,String   email,String   institute,String   phone,String   gender)
{
this.loginname=loginname;
this.username=username;
this.passwd=password;