标题:请高手指教 jsp登录问题
只看楼主
outman000
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2010-10-29
结帖率:55.56%
 问题点数:0 回复次数:1 
请高手指教 jsp登录问题
程序代码:
Login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  </head>
  <body>
     <form action="Loginaction.jsp" method="post">
     用户名:<input type="text" name="username"><br>
     密码:<input type="password" name="pwd"><br>
    教师:<input type="radio" name="flag" value="manager">
    学生:<input type="radio" name="flag" value="user"><br>
     <input type="submit" value="提交">
     </form>
     <a href="Register.jsp">注册</a>
  </body>
</html>
Loginaction.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ page import="java.sql.*" %>
<%@ page import="DB.UtilDb" %>
<%@ page import="beans.User"%>
<%@ page import="DAO.isLogin"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
    String username=request.getParameter("username");
    String pwd=request.getParameter("pwd");
    String Loginflag=request.getParameter("flag");
    System.out.print(Loginflag);
    if((!Loginflag.equalsIgnoreCase("user"))&&(!Loginflag.equalsIgnoreCase("manager")))
        {
            out.print("请选择登录对象");
            out.println("<meta http-equiv='refresh' content='2;url=Login.jsp'> ");
        }
        User use=new User();
        use.setUsername(username);
        use.setPwd(pwd);
        if(isLogin.Login(use,Loginflag))
        {
            session.setAttribute("admin",Loginflag);
            out.print("登录成功");
            out.println("<meta http-equiv='refresh' content='2;url=Main.jsp'> ");
        }
        else
        {
            out.print("用户名或者密码错误");
            out.println("<meta http-equiv='refresh' content='2;url=Login.jsp'> ");
        }

 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Loginaction.jsp</title>
  </head>
  <body>
     <br>
  </body>
</html>
loginaction 老是提示错误 if((!Loginflag.equalsIgnoreCase("user"))&&(!Loginflag.equalsIgnoreCase("manager")))
  请高手指教
搜索更多相关主题的帖子: PUBLIC 用户名 java 密码 HTML 
2011-05-13 12:16
sinister
Rank: 1
等 级:新手上路
帖 子:7
专家分:7
注 册:2011-1-27
得分:0 
  
String Loginflag=request.getParameter("flag");
//要先判断Loginflag不为null
{
            out.print("请选择登录对象");
            out.println("<meta http-equiv='refresh' content='2;url=Login.jsp'> ");
            return;  //这里要停止继续往下运行
  }

微机原理闹危机,随机过程随机过,实变函数学十遍,汇编语言不会编!
2011-05-31 18:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-339714-1-1.html




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

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