首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

jsp里使用bean出异常

2012-01-31 
jsp里使用bean出错误!用户注册功能,想在jsp里调用bean。bean的作用是查找现在数据库里是否有相同的用户名,

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;
this.email=email;
this.institute=institute;
this.phone=phone;
this.gender=gender;


  try
  {
    sql= "insert   into   sys_userinfo(loginname,password,username,gender,institute,email,phone)   values(   "   +   this.loginname   +   ", "   +   this.passwd   +   ", "   +   this.username   +   ", "   +   this.gender   +   ", "   +   this.institute   +   ", "   +   this.email   +   ", "   +   this.phone   +   ") ";
    stmt.executeUpdate(sql);
  }
  catch(Exception   e){};  
}
}


jsp   存放在项目的根目录下,类存放在根下的WEB-INF\src里
请问怎么解决问题,谢谢!

[解决办法]
> > > 类存放在根下的WEB-INF\src里
?!
编译好的class文件应该放在WEB-INF\classes下面

热点排行