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

jsp高手帮我解决个连接问题啊
我在连接到数据库,并作出判断后,为什么在执行if语句的内容时,他不能执行~
代码如下啊:
<%@   page   contentType= "text/html;charset=gb2312 "%>
<%@   page   import= "com.cruise.vo.* "%>
<%@   page   import= "com.cruise.dao.* "%>
<%@   page   import= "com.cruise.dao.impl.* "%>
<%@   page   import= "java.util.* "%>
<html>
<head>
        <title> 登陆   </title>
</head>
<body>

<%
        String   name=request.getParameter( "uname ");
        String   password=request.getParameter( "upass ");
        PersonDao dao=new   PersonDaoImpl();
        boolean   flag=false;
        Person   p=null;
%>        
<%
      try
      {
                p=dao.queryById(name);                
      }
      catch(Exception   e)
      {}    
      while(p!=null)
      {
              flag=true;
      }
%>


<%
        if(flag)
        {
              out.println( "验证成功 ");
%>
          <!--jsp:forward   page= "login_successDB.jsp "/-->
            <!--h1> 验证成功   </h1-->    
<%        
        }
    else
    {
  %>
          <!--jsp:forward   page= "login_failDB.jsp "/-->
          <h2> 验证失败 </h2>
          <jsp:forward   page= "login_successDB.jsp "/>
  <%  
    }
%>
       
</body>
</html>

各位大侠   帮忙看下哪里出了问题啊~~

------解决方案--------------------
Person p=null;
这个地方 这样写试一下
Person p=new Person ;
------解决方案--------------------
得先创建person实例.Person p=new Person ;

------解决方案--------------------
如果try {} catch{}中,得到的P不为null,while中是死循环.
------解决方案--------------------
while(p!=null)改为if(!p)