SSH登录,注册完整版5

 对应的jsp页面,如下,分别建立了index.jsp,success.jsp,failure.jsp,successinsert.jsp,failureinsert.jsp等。

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
     
    <title><bean:message key="welcome"/></title>     
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
    
     
 
<script type="text/javascript" src="validate/index.js"></script> 
   <script type="text/javascript">
   function changel(){
  
  
  var l=document.form2.sellanguage.value;
        

  if(l=="1"){
  document.form2.action="sell.do?request_locale=zh_CN";
    }
    if(l=="2"){         
   
    document.form2.action="sell.do?request_locale=en_US";
    }
   document.form2.submit();
  
   }              
  
   </script>                     
  </head>          
                         
  <body>   
  <form action="sell.do" method="post" name="form2">
  <select name="sellanguage" οnchange="changel()">
  <option>请选择语言</option>
   <option value="1">中文</option>
    <option value="2">English</option>
  </select>
  </form>
 
   <center>        
  
   <form action="person.do?status=dologin" method="post" name="form1" οnsubmit="return check(this)">
  
  <bean:message key="id"/>:
  <input type=text name="id" id="myid" οnblur="checkid()"
  οnfοcus="checkid2()"/>
 
  <span id="md"></span>
                    
  <br/>                  
                        
 <bean:message key="password"/>:
 <input type=password name="password" id="mypassword"    
  οnblur="checkpassword()"
  οnfοcus="checkpassword2()"
  />
 
 <span id="mp"></span>
 
 <br/>
  
   <input type=submit name="sub" value="<bean:message key="submit"/>"/>
   <input type=reset name="re" value="<bean:message key="reset"/>"/>
     
                              
  
          
   </form>
       
   <hr>      
   <hr/>
   <hr/>
   <form action="person.do?status=doinsert" method="post" name="form3">
   <bean:message key="id"/>: <input type=text name="id"><br/>
   <bean:message key="password"/>: <input type=text name="password"/><br/>
   <input type=submit name="sub" value="<bean:message key="submit"/>"/>
   <input type=reset name="re" value="<bean:message key="reset"/>"/>
     
                       
   </form>   
    
  
  
   </center>
  </body>
</html>
首页用到了客户端校验文件,单独建立在根目录下的validate下index.js

function check(){
 
 
if(form1.id.value.length==0){
 
                               
                                                                          
 
alert("用户ID不能为空!"); 
 return false; 

  
 
 if(form1.password.value.length==0){
  
  alert("用户密码不能为空!");
  
  return false;
  
 }
 
 return true;
 
 
}

 

 

 

 

function checkid(){
   
    var msg="the user's ID can't be null";
  // alert("the user's ID can't be null");
if(document.getElementById("myid").value.length==0){
  document.getElementById("md").innerText=msg;
  }
 
 
          
   }
   function checkid2(){             
                                                       
             
  // alert("the user's ID can't be null");
 if(document.getElementById("myid").value.length==0){
  document.getElementById("md").innerText="                    ";
         }
   }                                         
              
         
 
 function checkpassword(){
 
 var msgp="the user's password can't be null";
  if(document.getElementById("mypassword").value.length==0){
  document.getElementById("mp").innerText=msgp;
  }
 }
 
 function checkpassword2(){
 
if(document.getElementById("mypassword").value.length==0){
document.getElementById("mp").innerText="                    ";  
    
 } 
             }

                            

注册成功页面:

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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>
    <base href="<%=basePath%>">
   
    <title>My JSP 'successinsert.jsp' starting page</title>
   
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->

  </head>
 
  <body>
   添加成功
  </body>
</html>
注册失败页面:

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
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>
    <base href="<%=basePath%>">
   
    <title>My JSP 'successinsert.jsp' starting page</title>
   
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->

  </head>
 
  <body>
   添加失败,已存在本账号
  </body>
</html>
登录成功页面:

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>       
  <head>
    <base href="<%=basePath%>">
   
    <title><bean:message key="welcomepage"/></title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
  </head>
 
  <body>
     
   <bean:message key="welcomepage"/><br/>
   <bean:message key="welcome"/>        
 <bean:write name="mp" property="id"/>
   
         
         
   
   
  </body>
</html>
登录失败页面:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title><bean:message key="errorpage"/></title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
  </head>
 
  <body>
   <bean:message key="errorpage"/>
     <bean:write name="mp" property="id"/><br/>
        <bean:write name="mp" property="password"/><br/>
    
      
     </body> 
</html>

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值