String username = request.getParameter("username");
        String password = request.getParameter("password");
              
        %>
        <%
        if (username != null) { //如果用户名不为空,根据它来查试试
            try {
        %>
        <%
                Class.forName("com.mysql.jdbc.Driver");
             Connection    conn = DriverManager.getConnection(""""");
               Statement   pstmt = conn.createStatement();
                String sql = "select * from w "+" where w_name='" + username + "'" + " and w_password=‘" + password + "’";//查找username。password对应的数据                // pstmt.setString(1,request.getParameter("w_name"));
                //pstmt.setString(2,request.getParameter("w_password"));
             ResultSet    rs = pstmt.executeQuery(sql);  // 查询
               if(rs.next())                //如果有数据表示可以执行
                {  session.setAttribute( "login" , "ok" ); // 验证通过之后,跳转到后续页面
               session.setAttribute( "w_name" ,username);
        %>
            <jsp:forward page="hst5.jsp">
            <jsp:param name="" value=""/>
            </jsp:forward>
            <%
                }
                else {
            %>
                      <a href="hst1.jsp">账户密码错误,请重新登录</a>           <%
             }            } catch (Exception e) {
                e.printStackTrace();
            }       
        
        }
        %
这个一直显示的是空白页面,,在数据库中可以查到信息。不知道为什么。求助~~~~~~~~~~~~~~~

解决方案 »

  1.   

    你测试一下你的数据库连接,可能没有连接上,在每一步都弄一个out.pringln("x") 把相关信息打印出来
      

  2.   

    为什么把连接数据库的操作放在jsp页面进行呢? 后台的作用和前台的作用还是要分开好,建议最好不要混在一起搞。楼主分开来写试试!
      

  3.   

    Connection conn = DriverManager.getConnection(""""");
    请问你是故意不让我们看、还是没有写url?String username = request.getParameter("username");
    这下面随便打印一个信息 看到这个页面没?
    System.out.println("pass");我个人感觉是你接收到的username  等于空因为你判断若是进去了 、肯定会有异常显示的、
      

  4.   

    1、url写了。
    2、username?什么意思没看懂。我用String username = request.getParameter("username");
    这个语句。是来获得,来自上一个jsp文件输入的username和password。
      

  5.   

    这个程序运行的时候显示的是空白。源代码:<html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>        
            
                </body>
    </html>
    什么都没显示
      

  6.   

    String username = request.getParameter("username");
    你这后面打印这句话
    System.out.print(username);
    看出来值不、
      

  7.   

    看不出来。
    body>    
        源代码这个中间一直空白
        
     </body>
    还是空白页面
      

  8.   

    if (username != null) {
      你的一堆代码
    }else{    out.print("username为null");
    }
    这样加 在页面上就能看了、
      

  9.   

    控制台是指它生产的java吗?hst_jsp.java ??
      

  10.   

    这个加上去之后,单独运行这个hst.jsp是显示username为null的。
    但是我运行hst1,jsp 登录时,进入这个界面还是空白的。
      

  11.   

     
    这个是我hst1.jsp的文件
         <form action="hst.jsp">      账 号:<input type="text"name="username"><br>
          密 码:<input type="password"name="password"><br>
              <input type ="submit"name="submit">&nbsp
              <a href="hst2.jsp">  注册</a>
              </form>
      

  12.   

    hst.jsp这个全部贴出来、最好按格式贴下、