javabean问题
userinfo.java文件
package com.bxgl.zaly;
public class userinfo
{
private String username;
private String password;
public String getUsername()
{
return username;
}
public String getPassword()
{
return password;
}
public void setUsername(String username)
{
this.username=username;
}
public void serPassword(String password)
{
this.password=password;
}
}
userregist.java
package com.bxgl.zaly;
import java.sql.*;
public class userregist
{
Connection conn=null;
private userinfo usin;
public userregist()
{
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
String url= "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=data\bxgl.mdb ";
conn=DriverManager.getConnection(url);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void setUsin(userinfo usin)
{
this.usin=usin;
}
public void regist()throws Exception
{
String sql= "insert into user(username,password) values(?,?) ";
try
{
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setString(1,usin.getUsername());
pstmt.setString(2,usin.getPassword());
pstmt.executeUpdate();
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
}
}
newuser.jsp文件
<%@ page language= "java " contentType= "text/html;charset=gb2312 " import= "com.bxgl.zaly.* "%>
<jsp:useBean id= "usin " class= "com.bxgl.zaly.userinfo " scope= "page ">
<jsp:setProperty name= "usin " property= "* "/>
</jsp:useBean>
<jsp:useBean id= "regist " class= "com.bxgl.zaly.userregist " scope= "page "/>
<%
regist.setUsin(usin);
regist.regist();
out.println( "注册成功 ");
%>
报错内容
Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException com.bxgl.zaly.userregist.regist(userregist.java:34)
org.apache.jsp.newuser_jsp._jspService(newuser_jsp.java:72)
org.apache.jasper.runtime.HttpJspB