jsp简单的用户登录界面

1.用户登录界面

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>


<h1>   用户登陆界面</h1>


<form action="do_login.jsp" method="post" name="登陆界面">
 <table>
      <tr>
      <td>用户名:</td>
      <td><input type="text" name="username" > </td>
      </tr>
    
      <tr>
      <td>密码:</td>
      <td>  <input type="password"  name="password"></td>
      </tr>
     
      <tr>
      <td><input type="submit"  value="登陆"></td>
      </tr>
 
 
 
 </table>


2.登录信息处理界面

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户请求处理页面</title>
</head>
<body>
<% 
           String name="";
           String word="";
           name=request.getParameter("username");
           word=request.getParameter("password");
           request.setCharacterEncoding("utf-8");
           
           
           %>
           
           
           <%
           if("admin".equals(name)&& "admin".equals(word)){
          
          session.setAttribute("loginusername", name);
          //response.sendRedirect("success_login.jsp");
          
         request.getRequestDispatcher("success_login.jsp").forward(request, response);
          
           }else{
          
          response.sendRedirect("fail_login.jsp");
           }
           
           
           
           %>

3.登录成功提示页面

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>


<h1>登陆成功</h1>
<%  
    String  loginame="";
    if(session.getAttribute("loginusername")!=null){
    loginame=session.getAttribute("loginusername").toString();       
    }

  %>

    用户名为:<%= loginame %>

</body>
</html>

4.登录失败界面


<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>


<h1>登陆失败</h1>




<a href="login.jsp">返回登陆界面</a>

</body>
</html>

















发布了34 篇原创文章 · 获赞 11 · 访问量 3万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章