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

空指针问题``高手快来``
这个程序那里有问题吗?

<%@   page   contentType= "text/html;charset=gb2312 "%>
<%@   page   import= "java.sql.* "%>
<%@   page   import= "javax.sql.* "%>
<%@   page   import= "javax.naming.* "%>
<html>
<head> <title> jsp登录页面 </title> </head>
<body>
<center>
<%
        request.setCharacterEncoding( "gb2312 ");
        String   name=request.getParameter( "name ");
String   password=request.getParameter( "password ");
Connection   conn=null;
Statement   stmt=null;
PreparedStatement   pstmt=null;
ResultSet   rs=null;
String   sql=null;
%>

<%
                sql= "   select   *   from   zhuce   where   name=? ";
Context   ctx   =new   InitialContext();
DataSource   ds=(DataSource)ctx.lookup( "java:comp/env/jdbc/luntan ");
conn=ds.getConnection();
                rs=stmt.executeQuery(sql);
if(!rs.next())
                {
    try{
    pstmt=conn.prepareStatement( "insert   into   zhuce(name,password)values(?,?) ");  
    pstmt.setString(1,name);
    pstmt.setString(2,password);
    pstmt.executeQuery();
    out.println(name);
    out.println(password);
    }
    catch(Exception   e)
    {e.printStackTrace();}
%>
                          <jsp:forward   page= "success.jsp "/>
<%
        rs.close();
pstmt.close();
                conn.close();
}
else
{
%>
              <jspj:forward   page= "failure.jsp "/>
<%
        }
%>

</center>
</body>
</html>


<%@   page   contentType= "text/html;charset=gb2312 "%>
<html>
<head>
<title> 注册页面 </title>
</head>
<body>
<center>
<h1> 注册页面 </h1> <br>
<hr>
<br>
<br>
<br>
<form   action= "judge.jsp "   method= "post ">
<table>
<tr>
<td> 用户名: </td>
<td> <input   type= "text "   name= "name "/> </td>
</tr>
<tr>
<td> 密&nbsp;&nbsp码 </td>
<td> <input   type= "password "   name= "password "/> </td>
</tr>

<tr>
<td> <input   type= "submit "   value= "注册 "/> </td>
<td> <input   type= "reset "   value= "重置 "/