wenchunl

导航

 

login.jsp

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>Login page</title>
 8 <style type="text/css">
 9 body{
10     color:#000;
11     font-size:12px;
12     margin:0px auto;
13 }
14 </style>
15 
16 <script type="text/javascript">  
17     function check(form){  
18     //document.forms.form1.username.value取得form1中Username的值 并判断是否为空  
19         if(""==document.forms.form1.username.value){  
20         //如果 为""则弹出提示  
21             alert("pls input username");  
22             //将输入焦点定位到没有输入的地方  
23             document.forms.form1.username.focus();  
24             //返回错误  
25             return false;  
26         }  
27          if(""==document.forms.form1.password.value){  
28             alert("pls input password");  
29             document.forms.form1.password.focus();  
30             return false;  
31         }  
32     }  
33   
34 </script>
35 
36 </head>
37 <body>
38 <form action="loginDetails.jsp" method="post" name="form1">
39     <table border="1" cellspacing="1" cellpadding="1" bordercolor="silver" align="center">
40         <tr>
41             <td colspan="2" align="center" bgcolor="#e8e8e8">用户登录</td>
42         </tr>
43         <tr>
44             <td>用户名:</td>
45             <td><input type="text" name="username" /></td>
46         </tr>
47         <tr>  
48              <td>密码:</td>  
49              <td><input type="password" name="password"/></td>  
50           </tr>  
51           <tr>  
52               <!-- onclick="return check(this) 调用上面的Script进行验证 -->  
53             <td><input type="submit" name="submit" value="登录" onclick="return check(this);"/> <input type="reset" name="reset" value="重置"/></td>
54     </table>
55 </form>
56 
57 </body>
58 </html>

 

 loginDetails.jsp

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html>
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7 <title>The login details info page</title>
 8 </head>
 9 <body>
10     <%
11         String name=request.getParameter("username");
12         String pass=request.getParameter("password");
13         out.println("接收到的用户名:"+name);
14         out.println("接收到的密码:"+pass);
15     %>
16     
17 </body>
18 </html>

 

posted on 2017-03-30 14:25  良哥  阅读(2658)  评论(0编辑  收藏  举报