求助:while/if嵌套问题或者什么原因麻烦高手看下,急!!!!!!
<%@ page contentType= "text/html; charset=GB2312 " %>
<%@ page import= "qzd_shixi3.*,java.sql.* "%>
<html>
<head>
<title>
zhuce2
</title>
</head>
<body bgcolor= "#fffff0 ">
<%
String username=request.getParameter( "username ");
String cardno=request.getParameter( "cardno ");
String password=request.getParameter( "password ");
String sex=request.getParameter( "sex ");
String question=request.getParameter( "question ");
String answer=request.getParameter( "answer ");
String email=request.getParameter( "email ");
String qq=request.getParameter( "qq ");
if(username==null||cardno==null||password==null||sex==null||question==null||answer==null||email==null||qq==null){
%>
<p align= "center "> 注册失败!因为注册项不能为空! </p>
<%
}
else{
byte b[]=sex.getBytes( "ISO-8859-1 ");
sex=new String(b);
byte c[]=question.getBytes( "ISO-8859-1 ");
question=new String(c);
byte d[]=answer.getBytes( "ISO-8859-1 ");
answer=new String(d);
CONTROLDB con=new CONTROLDB();
String sql2= "select * from user ";
int i=0;
int j=0;
ResultSet rs=con.executeQuery(sql2);
while(rs.next()){
if((rs.getString( "username ")).equals(username)){
i=1;
}
if((rs.getString( "cardno ")).equals(cardno)){j=1;}
}
if(i==0){ if(j==0){
String sql= "insert into user(username,password,sex,question,answer,email,qq,cardno) values( ' "+username+ " ', ' "+password+ " ', ' "+sex+ " ', ' "+question+ " ', ' "+answer+ " ', ' "+email+ " ', ' "+qq+ " ', ' "+cardno+ " ') ";
con.executeUpdate(sql);
con.close();
response.sendRedirect( "register.jsp ");
}
}
else if(i==1){
%>
<p align= "center "> 用户名已经存在!注册失败! </p>
<%
}
else {
%>
<p align= "center "> 卡号已经存在!注册失败! </p>
<%
}
}
%>
<p align= "center "> <a href= "register1.jsp "> 返回 </a> </p>
</body>
</html>
jbuilder2005编译可以通过,执行出现错误。我觉得是while里面两个if的问题,请高手指点!!!谢谢~
[解决办法]
你试试out以下,在控制台看看输出了什么,你的两个if语句很简单,应该没问题,是你的语句逻辑有问题
[解决办法]
晕....怎么可能不允许某些嵌套
[解决办法]
.....
楼下还有人么,没有的话结贴勒
[解决办法]
JF