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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章