| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2516 人关注过本帖
标题:jsp求解 从login.jsp进入loginCl.jsp,但是loginCl.jsp没有处理,而且数据 ...
只看楼主 加入收藏
狼IT
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-5-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
jsp求解 从login.jsp进入loginCl.jsp,但是loginCl.jsp没有处理,而且数据库连接不上!!!???
这是登录界面 login.jsp
 <body bgcolor=pink>
  <center>
    用户登录 <br>
    <hr>
    <form action="loginCl.jsp" method="post">
    用户名:<input type="text" name="username"/><br>
    密&nbsp;&nbsp;码:<input type="password" name="passwd"/><br>
    <input type="submit" value="登录"/>
    <input type="reset" value="重置"/>
    </form>
    </center>
  </body>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
这是loginCl.jsp
<body>
  <%
           //接受用户名和密码
           String u=request.getParameter("username");
           String p=request.getParameter("passwd");
           //验证,
           try{
           //1.加载驱动
           Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
         
           //2.得到链接
           Connection ct=DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=users","sa","sa");
           //3.创建Statement
           Statement sm=ct.createStatement();
           //4.查询
           ResultSet rs=sm.executeQuery("select passwd from users1 where username='"+u+"'");
           //根据结果判断
         
           if(rs.next())
           {
               //说明用户名存在
               if(rs.getString(1).equals(p))
               {
                   //一定合法
                   response.sendRedirect("wel.jsp?user="+u);
                                 
               }else{
                   //密码错误
                   response.sendRedirect("login.jsp?errNo=1");
               }
           }else{
             //说明用户不存在
             response.sendRedirect("login.jsp?errNo=2");
                        
           }
           }catch(Exception e){
                e.printStackTrace();
           }
           
           
          /* if(u.equals("luo")&&p.equals("123")){
           //合法,跳转
           //如何将loginCl得到得数据传到下一个页面
           //1.cookie,2session,3.response.sendRedirect
                 
           response.sendRedirect("wel.jsp?user="+u);
           }else{
           //不合法
           response.sendRedirect("loginCl.jsp");
           }*/
           
  
  %>
   
   
  </body>
搜索更多相关主题的帖子: 数据库连接 password 用户登录 用户名 action 
2015-05-22 11:24
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
收藏
得分:20 
检查有没有启动sqlserver的服务
有没有加载驱动包
2015-05-22 15:44
快速回复:jsp求解 从login.jsp进入loginCl.jsp,但是loginCl.jsp没有处理,而且 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017312 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved